🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Project Protos: Day 3

Published March 12, 2009
Advertisement


Pew! Pew!

I haven't yet quite got the basics running yet. I've got a gun turret and a crosshair cursor working, but the bullets are still broken. I haven't yet figured out a good Flash way to implemenet them yet. It's the memory management aspect that's the issue. Flash's Arrays appear to be sparse, which means it's not straightforward to just delete a bullet, and I haven't found Flash's equivalent for a linked list yet. I might have to improvise something out of arrays.

Most of the delays come from my need to get up to speed and my unfamiliarity with Flash. I don't yet know all the library functions and variables, so I have to look everything up. Occasionally I'll hit something odd that takes a while to find the right fix.

I'm also a bit hamstrung in that it's been a while since I've written game logic, so I'm trying to remember all those little details like the best way to manage my code and deal with frame rate independent logic. For this project I've cut back on the planning and an just piling all the logic into one file, but there's a few cases where I've had to spill out into separate classes (and hence files; ActionScript is a bit like Java that way) for the sake of sanity. It's not pretty, but it doesn't need to be pretty.

Oh, and Flash's drawing tools are a bit crazy. This is a gripe I have with all of Adobe's tools, actually. I shelled out mad money for Adobe Creative Suite CS3 (well, I saved a bundle by getting an education discount, but it was still expensive), but the tools are some of the least intuitive I've used. Each tool seems to have multiple functions, and I don't get when each one is in effect. I admit I haven't given these tool enough time to do them justice, but that's usually because I've got a task to complete and if it's quicker to do it in GIMP, then that's what I'll fire up. Which is ironic, because GIMP's interface is no slouch in the WTF department itself. Inkscape's the only art tool I feel really at home with.

Back to Project Protos: at this rate, I figure I'll be up to designing the gameplay today. I haven't fully decided which direction to take this. The curret art is a placeholder and I don't know which style I'll end up using. I'll probably just knock together something a bit more vector-y in Inkscape and use that; see what works.
Previous Entry Project Protos: Day 2
0 likes 5 comments

Comments

johnhattan
I usually just let the items live at a certain location in the z-order and let the root be the array, like so. . .

firstbullet = 1000

var currentbullet = firstbullet
var done = false

while(!done)
{
if (!this[currentbullet])
{
addMovieClip("bullet", currentbullet, currentbullet)
done = true
}
else if (!this[currentbullet]._visible)
done = true
else
currentbullet++
}

// currentbullet is now the location of a bullet that's not in use
this[currentbullet]._visible = true
this[currentbullet]._x = whatever
this[currentbullet]._xdelta = whatever
etc. . .


Then when bullets die (hit something, go offscreen, etc), just set their visibility to false

And to update bullet positions. . .

var currentbullet = firstbullet

while(this[currentbullet])
{
if (this[currentbullet]._visible)
{
this[currentbullet]._x += this[currentbullet]._xdelta
this[currentbullet]._y += this[currentbullet]._ydelta
// see if the bullet hit something
}
currentbullet++
}
March 12, 2009 07:32 PM
Trapper Zoid
Quote: Original post by johnhattan
I usually just let the items live at a certain location in the z-order and let the root be the array, like so. . .

Thanks! I'll have to see something like that works, even if I use something like a container class for the bullets. I'm not sure if multiple bullets at the same z-order works in AS3, but it's not as if I'm an expert here!
March 12, 2009 08:02 PM
johnhattan
they're not at the same z-order. They're at 1000, 1001, 1002, etc.
March 12, 2009 08:27 PM
Trapper Zoid
Quote: Original post by johnhattan
they're not at the same z-order. They're at 1000, 1001, 1002, etc.

Ah, I see that now. I didn't know you could separate z-orders out like that.

I might stick with the linked list approach, simply because my brain appears to be coded in C. Once this little experiment is over I'll go back and look at nicer ways to solve the problem. I don't yet "get" Flash, in the sense of an intuitive understanding of what's going on under the hood, but I don't think I'll gain that understanding this game.

Edit: eh, or maybe not. Now I've read through your code snippet again it makes a fair amount of sense, and is probably better for a few bullets. I'll see. I do like coding up linked lists, though. It's just like the old days teaching algorithm classes! [grin]
March 12, 2009 09:14 PM
johnhattan
At its heart, ActionScript, like every other ECMAscript implementation, is a scheme interpreter. Don't do yourself a disservice and write a linked list because everything already is.

Give yourself a little time to wrap your head around things.
March 13, 2009 06:04 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement