C-Sharp

All posts tagged C-Sharp

Ok, so while creating my Agbar game, I wanted to play around with particles.  I’m think of making the world destroyable, and this would involve individual particles.

So, I created ParticleWorld.  The example is shown in the video below.


In this video, there are 7 sources of particles (in seven different colors).  One source sprouts up from the bottom middle like a fountain, two come up from the corners, two flow down from the corners, one sprouts in the center (almost like a firework), and there is a constant (orange colored) “rain”.

The debug information on the screen show the Processing FPS (60), Drawing FPS (30), the number of particles in each color and total particles (~7400). The final line shows the time it takes to process all 7400 particles (3-4ms running in a single thread on my 5+ year old Athlon X2 5000+, OCed to 3.2GHz).

Each particle maintains a constant, random X velocity (no air resistance, orange pixels have no lateral movement).  The Y velocity is subject to “normal” gravitational acceleration (9.81 pixels/second/second “down”). The rain is populated in a 1:50 ratio (roughly every 50th column gets a pixel each Processing cycle). Each “fountain” gets one new particle/per Processing cycle.

So anyway, I think it’s a pretty reasonable demo.  7400 independent particles updating at least 250 times per second (if the Processing cycle wasn’t locked to 60Hz) isn’t bad.  I could processing roughly 8 times this number of particles without any lag (at 60Hz).  So now all I need to do is figure out how to use this in my Agbar game.

Source is in my repo.

 

Back in high school, and friend and I wrote a 8-bit video game for our C++ class.  He wrote the graphics engine (this was Pre-DirectX/OpenGL technology), and I wrote the game engine.  I also did the graphics, but that’s not something I’m bragging about.  We tried to get a fried of ours who was studying to become a graphic designer to redo the images for us, but when we graduated high school we kinda lost track of the whole project.

Anyway,  armed with my 15-year old graphics, and nothing else, I decided to re-create the game in a modern setting (the old game doesn’t even run under DosBox 🙁 ).  Of course, being the genius that I am, I didn’t make a backup of the source code for the original game, literally all I have is the old graphics, the DOS-based map editor (which DOES run in DosBox), and a vague recollection of how the game worked.

I was going to use Microsoft XNA, but they stopped supporting that.  Instead I’m using C# and  MonoGame, a great open-source implementation of XNA functionality targeted for OpenGL (XNA is obviously DirectX).  And behold, the first screenshot is posted:

AgbarTest Level 1

AgbarTest Level 1

So, what does the game currently do?  It loads a pre-defined map, textures, sprites, etc…  Draws a world with the textures from the map.  Spawns our hero (Agbar, Sheep Destroyer, (nee Sheep Laser Tagger (long story) ) ), loads a couple of his most cunning adversaries (sheep), and lets you control the character.  Movement is with W A S D, firing left and right with Q and E respectively.  Jumping is the space bar.  The window scrolls with the character, missiles collide with bricks or sheep, sheep walk back and forth on platforms, character can climb ladders, and that’s it for now.

Video Demo:

In the original game, there were 4 types of enemies, landing on a potion bottle gave the hero magical flying/invincibility, and you could move through the doors (brown to brown to brown, etc…).  None of that is implemented yet, but I’ll work on it.  The original also drew everything palette-based (this was 8/16-bit DOS we’re talking about here), so the potions and candles used to blink thanks to palette-swapping.  That’s a thing of the past, so I guess I’ll need to draw more sprites.

The source is, of course, in my repository, so check it out (if you dare).  NOTES:  This needs .NET 4.0/4.5, OpenGL, OpenTK, and possibly OpenAL (though there is no sound).