Tag Archives: python

Wrote a Tile system!

Welcome back! I’m very happy to be working on the game again, after the brief hiatus. I made a grid system, as shown below. Here’s the latest thing little app I made, the colors and text is all just there for making the tiles visible, otherwise it’d be a blank screen :

Hit the jump for code examples, and what my old broken version of the code was.

Continue reading Wrote a Tile system!

Windows7x64 Wallpaper Changer Script

I’ve been meaning to make this ever since I discovered win32 stuff. It uses the .2 version of SendKey, found here, that uses ctypes, instead of the win32 stuff I think, as well as working with 64 bit Windows. Make a shortcut to it on your desktop and just run it as a .pyw file, in order to hide the terminal window that pops up. Simple stuff

Anyways, all it does is is simulate a right-click and then an ‘n’ keystroke. It’s just a quick little app,  just a dozen lines long:

import win32api, win32con
import SendKeys
def click(x=-1,y=-1):
    oldX, oldY = win32api.GetCursorPos()
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,x,y,0,0)
    win32api.SetCursorPos((oldX, oldY))

click()
SendKeys.SendKeys('n')

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.