Showing posts with label early. Show all posts
Showing posts with label early. Show all posts

Thursday, May 03, 2007

Alpha Strike

Colored in form, made the Cancel button work, and you can now add squads to your new airfleet for your big attack.

Soon I'll add a button called Alpha Strike that'll put all the squadrons into the attack airfleet list. Hey, that might even be a better name than Carrier Wave, too. Anyway, you can hold Ctrl or Shift to do multiple selections. Good old MultiExtended in the Listbox property does it automatically.




A simple click to move the squads to the right...



A small subtlety: see the below error I got when I first tried to add items to the right listbox and then remove them from the left listbox(listSquads). The error repeated three times in my errorlog file.

Thursday, May 03, 2007      9:34 PM
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Windows.Forms.ListBox.ItemArray.GetItem(Int32 virtualIndex, Int32 stateMask)
at System.Windows.Forms.ListBox.SelectedObjectCollection.get_Item(Int32 index)
at Carrier_Wave.frmCreateAirFleet.AddToAirFleet_Click(Object sender, EventArgs e)


Here was the Visual Basic.net code I had (shush, you C# fanatics):

For q = 0 to listSquads.SelectedItems.Count - 1
listAdded.Items.Add(listSquads.SelectedItems(q).ToString)
Next

'remove from
For q = 0 to listSquads.SelectedItems.Count - 1
listSquads.Items.Remove(listSquads.SelectedItems(q).ToString)
Next


I told it the last index (blah.Count-1) and then did a simple for...loop from 0 to the last index. Can you see the problem?

Scroll down a bit and you can see the fix was easy.

.
.
.
.
.
.
.
.
.
.

The removal of items from listSquads meant the last index was getting smaller and smaller. But the for loop kept going to the old, now too big, last index. So I did:

For q = listSquads.SelectedItems.Count - 1 To 0 Step -1
listAdded.Items.Add(listSquads.SelectedItems(q).ToString)
Next

'remove from
For q = listSquads.SelectedItems.Count - 1 To 0 Step -1
listSquads.Items.Remove(listSquads.SelectedItems(q).ToString)
Next


The last index causes the error unless you get rid of them first. Now we don't care if the number of items decreasing causes the last index to change. Basically, the bottom of the list is getting chopped off, but if we get the items at the bottom before that happens, then it doesn't matter.

Wednesday, May 02, 2007

Save the Donnas...

...and the Foolhardy, and the Hallowed. Save was implemented before but I'm more confident about it and Save regularly now. The game saves the new positions of the player and enemy fleets.

I moved the location variable from each individual ship and to the xmlFleet class. Updating each ship location was a pain when I tried to do it. Better to track fleets, which makes sense since there are few times where a player sends individual ships out and the game mechanic screams for abuse (play Russian roulette and split your fleet into 15 individual ships, then have the AI waste a bunch of attacks to find which are actually carriers!). I think I'll limit the fleet splitting to two or three and have any auxilary/transport fleets be separate and not count for the total.

Still working on Launch Air Strike:

Tuesday, May 01, 2007

Hard to Port! Teleport That Is...

Ships can do basic movement. Well, basic teleportations. The program calculates without the effects of speed and distance. I'll tackle later and hope the programming is dirt (distance is rate x time) simple...





As you can see in the pics, not too impressive, but it is progress. I added some code to increment the enemy Orange fleet's location and kept hitting the End Turn button until it went off the map.

I am trying not to get too excited, but I have so many ideas and keep coming up with new ones. From simple (save in xml so users can rename their own ships) to silly (make every form control configurable so the user can almost make their own UI) to complex (steal enemy tactics research by sending fighters to do hit and runs so they can observe enemy tactics and report back). There is a lot of work and struggling to do.

But I'm livin' the dream: making my own game.

Saturday, April 28, 2007

Carrier Wave: Week 0

So, this is the first news of my new game: Carrier Wave. Yes, I'm excited too. Here's a screenshot:

Free Image Hosting at www.ImageShack.us

Yeah, she ain't much now, but I got high hopes. Behind the scenes the program serializes classes into xml and back. So each ship gets its own node tree in the file. So that bit where it says the name of the ship? That gets saved into a fleet.xml file already. I have a shipdata object that is saved by each type of ship. Better than inheriting. Holy crap does that suck when you realize you made tons of design errors and changes in the parent start an unstoppable cascade of fixes for the child classes.

I started working with an actual game screen instead of menu system. At the place I work, I have a semi-working actually working program and I have to go through choosing Open > locate file, etc. before I can even get to my test page. Annoying. Some prgramming to automatically load my test save file saved me a lot of seconds throughout the day.