Tag Archives: programming

Learning C#

So I’ve been quiet the last few weeks, and that’s because I’ve been busy learning C#. I never got into it because I was always worried that it’d be archaic and obtuse to learn. That was compounded by the fact that I had tried C++ a few times, with Code::Blocks and I always got stuck with choosing a compiler or something. I really didn’t know what I was doing. Luckily, a friend of mine, sec_goat, convinced me to try out C#.

I’m really glad he did, because the whole language really isn’t as nasty as I was expecting. The compiler issue was taken care of by Visual Studio 2010 Pro, which I get for free from Microsoft DreamSpark, since I’m still in College. I’m actually still pretty fuzzy on the stuff that’s going on under the hood in C#, so I probably couldn’t compile my own project, but hey, it’s only been a few weeks.

Another reason I’m pretty stoked is that I’ve always wanted the be able to develop some games, and that just wasn’t easy in Python, because of how it runs. It’s super easy to get the design going, but unless you’d optimize the shit out of it, it’s going to run a bit slow. Now, not only can I develop games that’ll run at a decent pace, I can actually make games for the Xbox 360 too, with the XNA package.

It’s similar to PyGame as far as I can tell, but allows you to develop for the Xbox 360, and it’s integrated into Visual Studio quite nicely. It’s only a shame that I can’t use Visual Studio 2012 with it, without tweaking some files around; but that’s not a huge issue, since VS 2010 is pretty great anyways.

Relatedly, I’m using the VSvim plugin for Visual Studio, so a great majority of the vim controls are allowed. This greatly helps me learn vim. I have also set up gVim as an external tool, so whenever I hit F1, the code gets loaded into gVim for editing, should I ever need to do some extreme vimming.

Right now, we’re toying with the idea of making a Facebook pet raising game. Sec_goat is seeing what he can do as far as setting up a networked leaderboard, and I’m experimenting with making a tamigotchi clone. I’ve got a little console game going now that allows you to feed and do damage to your pet, along with an inventory system so you can store the food and a rudimentary status system where you can get buffs and debuffs such as happy or sick etc. I’m now trying to move the Console game to XNA, so I can make a graphical interface for it, along with having a true game loop, rather than just one prompt after another.

As far as tutorials go, that’s going to be put on the sidelines, if you can’t tell already. Like most people, I’m motivated by my own interests, so I just jump from project to project when it suits me. But if you’d like to get a simple tutorial on a Python feature, send me an email at tankorsmash@tankorsmash.com or on reddit under the username tankorsmash and maybe it’ll be the motivation I need to write another!

Thanks for reading, and as always,  I love hearing feedback. Ask me some questions or something!

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!

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!

Particle Simulator

Back from the break.

I decided to downgrade my project once again, because I guess my steps weren’t of a baby sized variation. In case you’re keeping track, it’s gone from the world’s best Python Roguelike, to a top down shooter, to a pong clone, and now finally, a particle simulator! I’m pretty sure this is a normal progression, because all it means is I’m learning what I’m capable of.

So anyways, I’m looking to create a simple physics simulator to fool around with, and I got stuck on what was a simple case of not using the right variables. Typical stuff, and then tonight I got stuck on inter-particle collisions, because once I got the wall collisions working I felt pretty good about it. Little did I know, life was going to get more complicated.

Pretty much we’re back to the beginning with the endless wall bouncing, and I’m not sure why exactly. The thing that seemed to cause it, is I’m resetting the list that contains all the rects of the particles, but as far as I know, the only thing that needs to use that list is the collision functions. The reason I wanted to reset that list every frame was just because I wasn’t updating the rects in it, so every collision test was testing against the original positions of the particles. Empyting and re-filling it every frame seemed to do the trick at first, but in the end, it seems like it didn’t really help at all.

Oh well, another night I’ll work through it and get it nice and functioning.

On another note, I’m going to try to write at least 200 words 3 times a week in order to build up my writing chops, and hopefully get a bit of a helping crowd going.

Talk to you Thursday!