Posts Tagged ‘Silverlight Games’

Locations and Radar

I added the locations (planets, moons, space stations, etc.) to the screen, and I’m about half done with the radar.  The max velocity has been cut from 20 to 10 px per frame.  It’s a bit easier to control.

I’m freekin’ thrilled about the radar.  I’ve been thinking about how that’s done in video games forever.  What I’m doing is scaling down the game world by a factor of 75…and that’s adjustable, of course.  I’ll have zoom in/out buttons on there pretty soon.  I stayed up a bit late to get the radar working, and it paid off.  It was the fulfillment of a lifelong dream when I pointed the ship toward a distant planet on the radar and saw it come into view on the main screen.

I need to learn how to use clipping in Silverlight to hide the radar blips that are outside the intended visible area.  I could turn them off manually, but that’s one more if statement to slow things down.  The way I’m doing the radar probably isn’t the most efficient anyway, but I’ll refactor it later.

The locations are stored in an XML file that has their coordinates, name of the corresponding image, and a brief description.  The same file contains the commodities I’ll use later in the game.

The consensus with amongst my work buds is that the steer-by-mouse needs to go, in favor of key controls.  I’m inclined to agree.

Latest version (a3) here.

Next steps:
– come up with a name
– make some graphics
– get the radar clipping done
– add some enemies to dispatch


Inertia fixed

Check out the latest version here.

After much thought and messing around, I realized that I needed to control the total velocity of the ship instead of trying to control the X and Y amounts separately.  So now I’m checking the velocity using Pythagoras’ handy theorem (a squared x b squared = c squared) and then scaling back the vector when it goes over the limit.

i still have some polishing to do, but here’s the code real quick…

double thrust = .27;

double velX = _playerVel.X;
double velY = _playerVel.Y;

double newX;
double newY;

double curRot = GetRotation();
pnl0.Text = “rot: ” + curRot;

Utils.CalculateMovement((int)curRot, thrust, out newX, out newY);

velX += newX;
velY += newY;

_playerVel = new Vector2D(velX, velY);

double veloc = Math.Sqrt(Math.Pow(_playerVel.X, 2) + Math.Pow(_playerVel.Y, 2));
pnl3.Text = “vel: ” + veloc;

double testVel = 20;

if (veloc > testVel)
double scale = testVel / veloc;
_playerVel.X = _playerVel.X * scale;
_playerVel.Y = _playerVel.Y * scale;

Now, fly around the galaxy yelling “Git some!  Git some!”  I’ll have something for you to shoot at pretty soon.


More futzing with the “drift” on my game.  I believe the correct term is “inertia”.  I really need to read that “pysics for game developers” book.

i simply took the ship’s current rotation and generated a vector from it based on an arbitrary thrust value, then added that to the ship’s current velocity vector.

like so:

CalculateMovement((int)curRot, .3, out newX, out newY); // this function ripped off from Silverlight Rocks

velocityX += newX;
velocityY += newY;

_playerVel = new Vector2D(velocityX, velocityY);     // i then use this vector to move my background layers, as well as the player’s position in the game universe.

And I have a check in there to make sure the ship doesn’t go too fast in any direction.   Before I had the check in there, the thing could go to warp speed in a few seconds.  It was a good test of my starfield generating algorithm, anyway.

So now I’m slipping and sliding all over the place.  It looks really good.   I’ve found a bug with my min/max check that I knew would happen, though.  More thinking and tweaking before I upload a new version.

Moving backgrounds

I was using a pretty lame technique to move the background starfield under the player’s ship and the more I struggled with it, the more I saw its flaws.  I had 4 panels, each was the same size as the game screen and a pretty nice starfield pattern.  I would move the panels according to the ship’s velocity and direction.  When one panel went offscreen, I would move it to the opposite side so it could be re-used.

My primary flaw in logic was that I had a cyclic error when testing to see if the panels’ x,y coordinates were less/greater/equal to the boundaries of the game.  I’d detect that panel 1 was off-screen, then place it in a position where it would then get picked up by another off-screen check and guess what?  You’d never see that panel again.  The equal-to part of the check was the main problem.

Anyway, I decided to use two overlapping randomly-generated starfields instead.  My offscreen checks are now nice and tight, and I can get funky with what happens in those checks (like change the star’s color or whatever).  The double-starfield looks sweet, too.  The top layer has 3-pixel stars and the bottom has 1-pixel stars.  The bottom layer moves a bit slower.  The effect pleases me.  I am pleased.  Yes.

Your first taste of Splodge Pre-Alpha .0001

The ship is ripped off from Lost Garden’s free game graphics collection.  I highly recommend Lost Garden for anybody noodling about in the indy game cosmos.  I’m probably going to use some of my kids’ art as soon as I get it digitized, or they’ll make some for me on their ‘puters.

Anywhooo, this is your first chance to test out Splodge Pre-Alpha v0.00001!  Some notes before you check it out:

– Click yer left mouse button to fire, use your mouse to aim/steer.
– Press W to accelerate, S to decelerate.  I don’t have fancy physics worked out so that your velocity/direction is dampened correctly when you turn and burn.
– I don’t have thrust sound or graphics yet.
– The laser shot sounds get clipped occasionally.  Still working on that.
– The stars are really cool.  Just keep that in mind.
– Be careful using Silverlight in Firefox (especially FF3, apparently).  I’ve seen it crash several times, and not on my stuff, but on the official site mostly.
– This build was made with Silverlight 2 Beta 2.

Some steps forward

Last night I decided that my Silverlight game wasn’t heading in the direction it should, so I went back to a previous iteration with some insights from my recent effort. I’ve had a problem getting the vision of the game solid in my head.

At first I had built a top-down, ship-centric shooter but I decided to try a map-driven, simpler game where you click on planets and then do your trading. I had the map part working nicely, but man it would have been a pretty dull game.

So mow I’m going for a model that’s much closer to Escape Velocity…top-down, player-in-the-center pew-pew game with a galactic map, commerce and weapon/ship upgrades. Last night I was able to (with the assistance of my older boy, Max) get a starfield moving under the ship, and move the ship around using velocity, etc. I still need to do the physics for thrust/velocity/turning, but for a guy that’s used to doing event-driven programming all the time, seeing this real-time action is pretty exciting.

One of the aspects of the game that I’m apprehensive about is building the AI for non-player ships (NPS? hehe). They’ll need to turn, thrust, fire weapons, target the player, etc. etc. Sometimes I think I’m getting a little too ambitious, but that’s what I need to do so I don’t get bored.

Where I am Now:

  • The game universe is 30000×30000 pixels. I generate a background starfield using about 7,000 randomly-placed white circles.
  • player ship in the center; a target reticle is moved by the mouse, which causes the ship to rotate to point at it.
  • ship fires lasers when the left mouse button is clicked. no sound yet.
  • ship increases velocity when the W key is pressed. the starfield moves in relation to the ships velocity/direction.
  • Map currently represents one solar system. You can click on a planet and your ship ( a totally different ship ) appears there.

Next steps:

  • Create the background more efficiently. The stars take too long to generate, IMHO, and maybe take up too much memory. I’m thinking a tiled bitmap would be better. Requires investigation.
  • Get the thrust/maneuvering to be fluid. Add some graphics for thrust, sound too.
  • Create a new data hierarchy to have star systems with planets/moons/stations. Each system should have a security rating, description, etc.
  • Refactor the map to show star systems and enable jumping between those systems.

Howdy, howdy, howdy.

Finally, a place where I can claim First Post.

I’m currently working on a Silverlight game based on the classic “Solar Wars” space commerce/cargo game (which is itself based on Dope Wars, et al). Another inspiration for this game is Ambrosia’s Escape Velocity. I spent countless hours being a galactic menace in that game. Other games in this genre are Elite, Privateer and Freelancer. I plan on eventually having a networked, persistent universe…but that’s far in the future. My dream is a low-rez, casual version of EVE Online.

My project is a top-view game with two main modes: a map of the solar system or galaxy, and a commerce mode where the player can buy/sell commodities. The player tries to buy low, sell high, and transport special cargo in order to make money to upgrade his/her ship in order to make more money, etc. ad infinitum.

The first iteration of the game will be strictly event-driven. Click on a planet/space station to travel, and then do your commerce, maybe buy some upgrades or take a mission, then it’s back to the map. The player will start with a small, unarmed shuttle capable of carrying a small amount of cargo.

I have no idea what to name the thing yet. I’m sure my 6 and 8 year old boys will come up with something catchy.

So far I’m enjoying Silverlight and XAML.  It’s like working with any other taggy paradigm (html, xslt, etc.) so I’m comfortable with the angle brackets and attributes.  Man, it’s verbose though.  And a bit odd.  The first thing that really showed me how different XAML is from HTML is the way tables (grids) are built…the grid is fully defined before any content is added.  Then when you add the content you tell it which row/column to pop into.  Pretty nifty.

I can’t wait to get into doing some styles in XAML.  I can tell it’ll be handy as hell (much like CSS), but I can’t quite wrap my head around it yet.  I’ve only had a few hours’ experience so I’m a bit clumsy when it comes to remembering all the setter property thingies and whatnot.  Fortunately I found a tool called Kaxaml which should help quite a bit.  If you’re new to XAML or just want another wicked-handy tool, I highly recommend it.  It’s free (as in beer).  May the gods bless Robby Ingebretsen.