Jay McGavren's Journal

2008-03-03

Ain't they cute?

view = TrailsView.new(
	:width => WIDTH,
	:height => HEIGHT,
	:scale => 0.5,
	:origin => Location.new(-200, -100)
)

scale_origin.PNG

This is another prerequisite to a 2D shooter. Scrolling should be a matter of:

View#origin.y -= SCROLL_RATE * clock.elapsed_time

Some kind of factory can spawn enemies from a YAML file as the player approaches them, and delete them after he passes them.

Read more...
2008-02-29

creature.name = ‘Neo'

A huge feature I’d always meant to include in Zyps but had thus far left out: bullet time. On a whim today, I tried adding it, and it took all of 2 minutes…

class Clock
	def initialize
		@@speed = 1
		reset_elapsed_time
	end
...
	#Returns the time in (fractional) seconds since this method was last called (or on the first call, time since the Clock was created).
	def elapsed_time
		time = Time.new.to_f
		elapsed_time = time - @last_check_time
		@last_check_time = time
		elapsed_time * @@speed
	end
...
	#Speed at which all Clocks are operating.
	def Clock.speed; @@speed; end
	#Set speed at which all Clocks will operate.
	#1 is real-time, 2 is double speed, 0 is paused.
	def Clock.speed=(value); @@speed = value; end

So far it seems to Just Work, but I have a lot of unit testing ahead before I’ll declare that with confidence.

One other enhancement I may try is the ability to set a Clock instance’s speed in addition to the global speed. So you could pick up a power-up and suddenly be moving twice as fast as your environment or some such.

Read more...
2008-02-28

Die, die, die!!!!

Presenting ShootAction:

shootaction.png

Read more...
2008-02-27

coerce()

Wow.

Normally, Vector expects its pitch to be a floating point number, or some kind of number. Well, how powerful would it be if I could say this:

object.vector.pitch = RandomValue.new(360)

…and have RandomValue present itself as a different random number each time it’s accessed?

Turns out I can:

Read more...
2008-02-27

Wow. Git on Windows is janky and scary right now.

Wired had that article eons ago with a fictitious letter from Linus Torvalds to Bill Gates, hashing out some issues arising from a version of Windows that ran on top of Linux. I would really, really like to see that come true.

Read more...