Zebab.dk Sebastian Riege Warnez

5Apr/10Off

DirectX!

Playing around with C++ and some terrain generation. Samples are generated from a BMP, using colors as heightmap. Code to follow.

Happy Easter:

Terrain:

22Sep/090

Hello World!

So I had some time tonight to mess around with Box2D in flash, and I made my first Hello World application! It's not pretty, since it was made in 2 hours, but I hope you like it! :)

Get Adobe Flash player

See below for the actionscript code. Note that I use symbols inside a .fla file for the sprites. You can get the .fla file here.

 
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
 
	import Box2D.Dynamics.*;
	import Box2D.Collision.*;
	import Box2D.Collision.Shapes.*;
	import Box2D.Common.Math.*;
 
	public class HelloWorld extends Sprite
	{
		public var the_world:b2World;
 
		// This is done since Box2D scales up by 30
		// Multiply with ps to get proper position
		public var ps:Number = 30; 
 
		//Use this function to calculate size
		public function realPixels(n:Number):Number
		{
			return (n / ps / 2);
		}
 
		public function HelloWorld()
		{
			var environment:b2AABB = new b2AABB();
			environment.lowerBound.Set(-100.0, -100.0);
			environment.upperBound.Set(100.0, 100.0);
 
			var gravity:b2Vec2=new b2Vec2(0.0, 10.0);
			the_world=new b2World(environment, gravity, true);
 
			// Create ground
			var groundW:Number = realPixels(650);
			var groundH:Number = realPixels(20);
			var groundX:Number = 300 / ps;
			var groundY:Number = 400 / ps;
 
			var bodyDef:b2BodyDef = new b2BodyDef();
			bodyDef.position.Set(groundX, groundY);
 
			var boxDef:b2PolygonDef = new b2PolygonDef();
			boxDef.SetAsBox(groundW, groundH);
			boxDef.friction = 0.3;
			boxDef.density = 0; // static
 
			bodyDef.userData = new ground();
			bodyDef.userData.width = groundW * ps * 2;
			bodyDef.userData.height = groundH * ps * 2;
			addChild(bodyDef.userData);
 
			var body:b2Body = the_world.CreateBody(bodyDef);
			body.CreateShape(boxDef);
			body.SetMassFromShapes();
 
			// Create boxes
			createBox(80, 190, 30, 30, new boxH());
			createBox(100, 150, 30, 30, new boxE());
			createBox(120, 110, 30, 30, new boxL());
			createBox(140, 70, 30, 30, new boxL());
			createBox(160, 30, 30, 30, new boxO());
 
			createBox(300, 190, 30, 30, new boxW());
			createBox(320, 150, 30, 30, new boxO());
			createBox(340, 110, 30, 30, new boxR());
			createBox(360, 70, 30, 30, new boxL());
			createBox(380, 30, 30, 30, new boxD());
 
			addEventListener(Event.ENTER_FRAME, on_enter_frame);
		}
 
		public function createBox(x:Number, y:Number, w:Number, h:Number, sprite:Sprite):void
		{
			var ww:Number = realPixels(w);
			var hh:Number = realPixels(h);
			var xx:Number = x / ps;
			var yy:Number = y / ps;			
 
			var bodyDef:b2BodyDef = new b2BodyDef();
			bodyDef.position.Set(xx, yy);
 
			var boxDef:b2PolygonDef = new b2PolygonDef();
			boxDef.SetAsBox(ww, hh);
			boxDef.friction = 0.3;
			boxDef.density = 1; // dynamic
 
			bodyDef.userData = sprite;
			bodyDef.userData.width = ww * ps * 2;
			bodyDef.userData.height = hh * ps * 2;
			addChild(bodyDef.userData);
 
			var body:b2Body = the_world.CreateBody(bodyDef);
			body.CreateShape(boxDef);
			body.SetMassFromShapes();
		}
 
		public function on_enter_frame(e:Event)
		{
			the_world.Step(1/30, 10);
 
			// Update sprites according to body
			for (var bb:b2Body = the_world.m_bodyList; bb; bb = bb.m_next) {
				if (bb.GetUserData() != null)
				{
					bb.m_userData.x = bb.GetPosition().x * ps;
					bb.m_userData.y = bb.GetPosition().y * ps;
					bb.m_userData.rotation = bb.GetAngle() * (180/Math.PI) % 360;
				}
			}
		}
	}
}
 
19Sep/090

Embedded flash test

This post is just to test how to embed flash into posts.


Get Adobe Flash player

19Sep/090

New Blog

So I've moved to Wordpress, mostly to try it out, but keep an eye out for updates! I might start posting code snippets on stuff I'm messing with at the moment :)

Filed under: Uncategorized No Comments
1Dec/080

Nordic Game Jam 2008

Attended the Nordic Game Jam 2008. The game we did was about torturing little fluffy animals for information, before returning to base. It was a fast-paced 4 player game, where each player could also steal the information from other players and returning it to their own base.

This time it was a little less serious, but still great fun. Got to play with XNA again, this time in 3D - although that might not have been the best solution for the game we made. The "Noone expects the spanish inquisition" bit from Monthy Python got sneaked into the games as well, popping up randomly ingame, made us chuckle quite a lot. Hmmmm, must be funnier when you haven't slept for 2 days..

We did have some issues right at the end with some source control not working properly, so the version we released contained some bugs we got fixed 20 minutes after deadline. Ah well..

Check out Torturama here.

5Feb/070

Nordic Game Jam 2007

Attended the Nordic Game Jam this weekend. The idea was to create a game in a weekend, while meeting at least 3 of the following 5 demands:

  • Must contain a reference to Nordic culture ( eg. stories/art/design/music)
  • Must have more than one way to complete the game (eg. negotiations / kill all)
  • Must contain H2O in some form (water/ice/steam)
  • Must have a time limit
  • Must be playable with one hand

My group (Team Strong) was comprised of yours truly, Jesper Rasmussen, Alessandro Canossa, René Sinnback, Jesper Taxbøl and Thorbjørn Sørensen. Our game is very simple: You play a hungry shark and you happen to bask in a coral reef full of tasty fish. Troubles start when you find out that there are NO controls! You should in fact use the pitch of your voice (High pitch is up, low pitch is down) to negociate obstacles and fill your stomach. All of this in 20 seconds.

The hardest part was to implement the sound controlling, especially since XNA does not have any sound input.

My group ran off with the Jury's Award (The jury being comprised of 6 people from the industry). The people's award (participants vote) went to "Baa-aah! The Lords are our Shepherds". All games will be uploaded to the NGJ2007 site with more info and pictures of the event.

Get Sharcry here. You will need the XNA Framework, some optional directX stuff, the .NET Framework and a microphone to play the game. Please bear in mind that the game was created in 48 hours - so bugs may occur. See here for screenshots. Please contact me with bugs, comments, suggestions or general rants :-)

For more info, visit: Nordic Game Jam 2007 and diginet.