UI is in!

edit: the formatting is all messed up. Sorry.

 

Making some progress! With the UI boxes set up, I’ve realized it’s looking a bit more like a legitimate game, which is really exciting for me. Unfortunately, it just makes it more obvious to me though that I have so much work to do! Take a look:

I decided to redo the way I draw the sprites every frame. Initially I had the sprites load from disk every frame, and then select the appropriate sprite to draw, which was fine for just one or two sprites on screen, but as I put more and more baddies on the screen, it became clear that there was a massive performance hit, and I really want this game to run as best as it can, at least for now, since there aren’t many features. To make a long story short, instead of reloading the sprites every frame, I just save the sprites to the instance class, and pull the sprites from there, which is a better idea, because the sprites aren’t going to change on disk at all, at least while the game is running.

Moving forward, I haven’t done much reading into the theory of how to design a game properly, so I’m usually doing what seems like it would work in the short term, generally putting the long term out of my mind until I get a better idea of what I’m trying to do. For example, my modules are really just split into smaller parts in no particular order; they’re just split up in a way that makes it easier for me to find the function I want to. I’m sure I’ll have to move stuff around later.

Also, I’ve fixed the bullets not rotating properly, and I added the exhaust flames to show only when the actors are moving, which I think is a nice touch.

As far as game basics left to go, I haven’t even touched AI in months, so the NPCs just sit there, facing right! I still haven’t implemented delta time (if that’s the right name for it), so if my logic starts getting slow, my whole game gets unresponsive, which isn’t good, for the obvious reasons. I’d like to implement a stats screen that you can open up on the fly too, so that means I need a way to pause the game, which means I need to implement game states. That is to say, I need to be able to tell the game when it should try to move the characters or keep ‘em still. Hopefully that won’t be too tough of an issue.

Popup Box

Today, I’ve created a popup dialog that will be used to display information to the player. It’s nothing to look at, but I feel like it’s important to get right, since the player will be spend a lot of their non-active gameplay time reading them, and it the popups don’t look right, then the game won’t feel as well put together as it otherwise might. I figure I’ll add an option to slowly scale it smaller and smaller, and also fadeout, just so I can broaden its use throughout my code. Once I get the scaling set, I can also start to implement damage numbers, because I once swore to myself that my game would have numbers everywhere.

In fact, this is a good time to mention that my game will have a stupid amount of stat tracking. Like everything possible will be tracked, and hopefully exported to xml or something so you can browse it yourself. I’m talking like amount of times you pressed a given key, or hit or missed something, or the average amount of experience you’ve earned in the first 5 minutes of the game. Little things like that, things that no one really thinks about, but I’m sure there’ll be one fan that is all about stats, and he’ll love it. I don’t know if it’ll drain the memory though, Python’s pretty slow already.

Hit the jump for an explanation of how I wrote my word wrapping , autosizing popup box.

Continue reading Popup Box

Added Graphics!

I’ve recently made some progress for my shooter game! I’ve found the equation I’ve needed to find the point where the slope of the direction crosses the boundaries of the rect for the players, with the intention of having a good starting point for bullets to spawn from. It’s also a great way to determine all the points in the perimeter, obviously. But anyways, here’s the code:

#----------------------------------------------------------------------
def sign(x):
    """returns the sign of x: -1, 0, or 1"""

    return cmp(x, 0)

#----------------------------------------------------------------------
def intersect_perimeter(x, y, w, h):
     """finds the intersection in a rectangle"""

     #if check which side to put the point on
     if abs(y*w) > abs(x*h):
         return (int(0.5*h * x/abs(y)), int(0.5*h * sin(y)))
     else:
         return (int(0.5*w * sin(x)), int(0.5*w * y/abs(x)))

I’ve also had the chance to implement some cheap graphics, including bullets, explosions, and a house, drawn by me, but also a background image, drawn by the most angry of my friends. The results are pretty nice, definitely an improvement over the old off-white background. You can see the player, flames behind him, the place holder house, and the background

Continue reading Added Graphics!

Quick Update

I drew some flames, and posted to /r/gamedev, so I figured I’d mirror it here

http://imgur.com/WggC5

Just added some flames to the dudes. It’s gonna be a topdown shooter ala Geometry Wars and Gatling Gears.

This week I’m going to try to add a background, put shooting back in and scoring.

 

In related news, I’ve made the game redraw and reload the sprites every frame, which comes out to about 60 times a second, if that’s not a drain on performance, I don’t know what it. Luckily, or perhaps not, my PC is tougher than my 4 year old laptop, so it’s taking the load happily.

I’m going to rewrite the shooting this week, like I mentioned, but I’d really like to add seeker missiles, but I’m not quite sure yet how to make the missiles turn gradually. I don’t think it will be that tough, just rotate the sprite a bit every time and adjust the speed, but I’m going to have to take a look at the trig math behind it to choose a function that gradually speeds up and slows down.

Anyways, hopefully I’ll have the time to write a more full post later.

Rewriting Project Shooter !

After a good discussion with a friend of mine, I decided to take a stab at rewriting, once again, Project Squares, not renamed Project Shooter. So far it’s only ~600 lines, including white space and comments, but it’s quite a bit cleaner, neater, and more compact, not to mention commented to bits!

What it is right now is one character instance moving around, but only in one direction. The direction can be changed to west or southwest right now, but as soon as I get back to it, I think I’ll be able to make mouse control a possibilty, allowing for 360degree movement, which will be really nice. It was really important for me to get that character rotation down, as my old code had really gone to hell, and so I wasn’t able to go through it and make changes to it without a ton of headaches. Rewriting and refactoring was definitely the right choice here for me.

I have several things to implement left though, until I’m back to where I was, pre-rewrite: mouse movement, shooting component, which contains hp, damage dealing, kill tracking among other stats. I have to re-implement a display for the frames per second, incidentally, I created a question over at /r/learnpython and got some great responses, as usual. There’s also the AI component I have to re-implement; all that was was a timer that went off every 1/2 second and either moved or rotated the NPCs. If it saw the player during the rotation phase, it would stop rotating and start firing until the next movement phase. There was still never really a high risk of being hit though, since the enemies still fired in a straight line ahead of themselves, unless there was a high amount of enemies. Addionally, I had made use of a module called txtlib which allows PyGame to print on multiline, as well as color, if I’m not mistaken.

I used the builtin glob package, which crawls along folders, but my understanding of it is embarrassingly limited, but I assume should the need to crawl my folders arise again, I will be able to quickly gain a better understanding.

New in this iteration is the simple function that gives each instance of a character a random name, chosen randomly, using the random module, from a list of American Male Names. It’s only a few lines long, but I still feel pretty smart writing it.

I’ll end this entry with a before and after picture of my shooter.

A blog about gamedev and vim