Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
I may be slow to respond.

taryn phrohdoh

🤔
I may be slow to respond.
View GitHub Profile
View Game.cs
public class Game
{
Sdl2Graphics window;
public static void Main(string[] args)
{
window = new Sdl2Graphics(new Size(450, 450));
}
}
View gist:622b1551c9bb3e237be8
2014-07-07 21:48:23.057 mono[699:507]
No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting
/Users/thill/Projects/FNATestGame/FNATestGame/Info.plist
/Users/thill/Projects/FNATestGame/FNATestGame/bin/Debug/FNATestGame.app/Contents/Info.plist
View Game.cs
using System;
using System.Drawing;
using SDL2TestGame.RendererSDL2;
namespace SDL2TestGame
{
public class Game
{
static Sdl2Graphics window;
View Sdl2Window.cs
public void DrawSomeRect()
{
SDL.SDL_SetRenderDrawColor(renderer, 0, 175, 175, 0);
SDL.SDL_RenderClear(renderer);
var rectangle = new SDL.SDL_Rect();
rectangle.x = rectangle.y = 50;
rectangle.w = rectangle.h = 50;
SDL.SDL_RenderDrawRect(renderer, ref rectangle);
View ClonesProducedUnits.cs
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
@phrohdoh
phrohdoh / SpeedQuestion.cs
Last active Aug 29, 2015
Which is faster? I assume the first.
View SpeedQuestion.cs
var near = self.World.FindActorsInCircle(self.CenterPosition, info.Range);
foreach (var actor in near)
{
var foo = actor.TraitOrDefault<FooBar>();
if (foo == null) return;
// do stuff
}
var near = self.World.FindActorsInCircle(self.CenterPosition, info.Range)
.Where(a => a.HasTrait<FooBar>());
View ChainAttacks.cs
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
View AutoTarget.cs
// existing code
Actor ChooseTarget(Actor self, WRange range)
{
nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval);
var inRange = self.World.FindActorsInCircle(self.CenterPosition, range);
return inRange
.Where(a =>
a.AppearsHostileTo(self) &&
!a.HasTrait<AutoTargetIgnore>() &&
View ParaDrop.cs
class ParadropOrderTargeter : IOrderTargeter
{
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
var location = self.World.Map.CellContaining(target.CenterPosition);
if (!self.World.Map.Contains(location))
return false;
View ParaDrop.cs
class ParaDropOrderGenerator : IOrderGenerator
{
Actor self;
public ParaDropOrderGenerator(Actor self) { this.self = self; }
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{
if (mi.Button == Game.mouseButtonPreference.Action)
yield return new Order("DoParadrop", self, false) { TargetLocation = xy };