9 of 9
9
“Gw0rp” Developer Diary by Stephen Johnson (diordna)
Posted: 07 December 2008 10:22 PM   [ Ignore ]   [ # 121 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

Apparently, Chipmunk won’t let me update shape offsets, so I have to destroy and recreate shapes every time I add a new shape with mass to a body. If there is a speed hit, it won’t be significant since the game will pause automatically anyway in order to ask the player for a key assignment.

The first mini-screenshot has been attached to this post.

Addendum: I forgot to mention earlier that Psyco is amazing. I got a 30 FPS boost by inserting two lines of code:

import psyco
psyco
.full() 

Image Attachments
gw0rp1.png
 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
Posted: 07 December 2008 06:12 PM   [ Ignore ]   [ # 122 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

You’ll see screenshots when there are screens worth shooting.

 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
Posted: 07 December 2008 05:56 PM   [ Ignore ]   [ # 123 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

As of today, all of the important math-related code is finished. In Chipmunk, only bodies have mass, but in gw0rp, each shape represents mass, while the body merely attaches them. In Chipmunk, shape placement specifies distance from the center of mass, but in gw0rp, the center of mass depends on shape placement. To get around these opposite design philosophies, I wrote a method that calculates the center of mass based on shape placement, translates all existing shapes relative to the body, and moves the body’s position to compensate for the change in shape placement. I hope Chipmunk won’t have problems with this when I do it in real time, but so far it seems solid.

I also made some preliminary graphics for all the unit types that look more or less like the design document, only better.

 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
Posted: 05 December 2008 02:51 PM   [ Ignore ]   [ # 124 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

Team Addition
Today I recruited Rob Wiesler to help work on the code. The team is getting a bit big, but don’t worry, we’ve got a Facebook group!

I’m gathering so many people because of a fundamental law of physics: although it takes more force to accelerate a large object, it also takes more force to stop it. In theory, a team with enough of the right people will help me get through the inevitable dry period.

 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
Posted: 05 December 2008 11:19 AM   [ Ignore ]   [ # 125 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

I had a relatively tough time figuring out Chipmunk Physics, so I’m going to write down the basic steps here for the benefit of whomever.

Things You Must Do to Make Chipmunks and Pythons Play Nice

Download pymunk.

Import and initialize pymunk:

import pymunk
pymunk
.init_pymunk() 

Create a Space, give it gravity, and resize the hashes:
space pymunk.Space()
space.gravity pymunk.Vec2D(0,-900#tweak to your liking
space.resize_static_hash()
space.resize_active_hash() 

Create a static body to attach immobile shapes to:
static_body pymunk.Body(pymunk.infpymunk.inf

To make an object, you need to create a Body, which has mass, inertia, and a position, and attach shapes to it, which give it volume. I don’t have a good small code sample for this, but the documentation is pretty clear about this. Look through the examples for some straightforward test values. Make sure you add the body and any shapes you attach to your space with space.add().

You can attach as many shapes as you like to a body. If you don’t want the shape to move, then attach it to static_body.

Use Body.local_to_world(shape.offset) to get the position of a shape.

Note About gw0rp
Gw0rp blurs the lines between shapes and bodies, since each shape represents what was once a body, so I have to be careful to set the body’s mass to the sum of its parts, and approximate the whole body’s moment of inertia with decent accuracy. My current approximation is:

for this_unit in shapes_in_body:
    
offset_r math.sqrt(this_unit.offset[0]**2+this_unit.offset[1]**2#distance from body center
    
body_mass += this_unit.mass
    body_inertia 
+= pymunk.moment_for_circle(this_unit.massoffset_r-this_unit.radius/2offset_r+this_unit.radius/2,(0,0)) 

It seems to work well enough.

 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
Posted: 04 December 2008 11:12 PM   [ Ignore ]   [ # 126 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

Warning: long post, which I am writing mainly because I will forget most of this information soon and want to get it down somewhere.

I learned to program in 4th grade, around 1998. The first game I wrote was a text-based Pokemon battle game. Eventually, I found Visual MacStandardBasic and GameMaker by Al Staffieri and made the sorts of programs one would expect a middle school student to make.

I discovered iDevGames in 2003 just one week before the entry deadline for uDevGame (no trailing ‘s’). In a now-familiar burst of productivity, I wrote AstroBattle in VisualMacStandardBasic. It was very simple, with two human-controlled ships trying to hit each other with short lasers. In retrospect, it was a bit like Joust, but without AI. Not knowing a thing about how to render graphics, I drew both players by putting two picture controls on a form and changing their positions in code. I didn’t do well in the contest, but I got my first taste of real game programming.

Soon after the end of the 2003 contest, I discovered MetaL BASIC, an easy but limited language that made it easy to draw graphics, get keyboard input, and play audio. I wrote a game called Canvas Wars after a few months of experimentation and entered it in a small iDG contest. The object of the game was to cover the screen with your color of paint, laid down by something like a toy car, if a toy car was a circle with a line indicating direction. Some feedback excerpts from an old, old topic on Jake Leveto’s web site:

…this game is very simple and funny, the graphics are poor and little developed, the main idea is original but the CPU player is totally random and don’t offer any difficulty (to win the game, simply follow your opponent, covering its color).

Very original idea… unfortunately graphics are lacking. Menu colors and stuff are pretty cool, but the options/setup menu is too flashy (no, literally).

…very original, and had lots of cool power-ups. Not much replay value.

I cleaned up Canvas Wars and released a 1.1 version that got some nice reviews on MacUpdate. You can’t get it anymore.

The first “21 Days Later” contest was during the spring of 2004. I wanted to clone an old Mac Classic game called Continuum. I called my entry PastBlasters. It was a top-down free-scrolling indoor spaceship shooting game, with all sprites rendered as scalable vector graphics. In retrospect, I had already outgrown MetaL BASIC – it had no functions, no return statements, no parameter passing, and no data types beyond primitives and arrays. To get around these limitations, I was simulating parameter passing with “param1, param2…” globals and simulating structs with multidimensional arrays. I was reading books about Java, but none of them gave me any information about displaying raw graphics rather than GUI components, so I felt stuck. I didn’t do well in the contest, in part because someone else made essentially the same game as I did, but better.

I drew up a somewhat more ambitious plan for uDevGame 2004. I wanted to make four games in one. The best one was an isometric dungeon escape puzzle game. It worked well and was relatively engaging. The other three turned into two and were relatively uninteresting – a half-baked artillery game and a half-baked boat game. I did better than I had done the previous year, but I was still in the bottom 50%. I don’t even remember what the game was called, and I can’t retrieve it due to the Great Hard Drive Wipe of ’04.

In early 2005, I became a beta tester for BlitzMax, an environment tailored specifically to games. The language was clunky, but it was fast and well-supported. The first game I made was Canvas Wars 2, which never really got released, even though all the major features had been implemented. After Canvas Wars 2, I started working on a PastBlasters remake called gw0rp. (Here’s the old iDevGames topic I posted about it.) I lost interest in it after a while.

I participated in some contests, but didn’t get very far until 2005, when Will Hogben and I took first place in the first Original Mac Games contest. (No, Freeverse never published Escort Wing 2. I was never involved in it.)

I didn’t enter uDevGame 2005, but there was a 21 Days Later for 2006, which I won with Artack. First prize for that contest was Stone Design’s Create, which I used to produce gw0rp’s design document this year. I would have made Artack 2, but Sketchfighter came out the December after the contest, and I decided that there were enough After that, I stopped making games for a while, concentrating on homework and other hobbies during my first year of college.

I had experimented with Python in 2007, but the PyGame library frustrated me then, and continues to do so today. In 2008, I read about Pyglet and started using Python again, with a reimplementation of gw0rp as my first project. This time, I stopped even earlier because it ceased to be interesting. I kept writing in Python, though, and eventually entered PyWeek 7 with Josh Cender. The game we made was called Elite Bungie Chopper Squadron. Josh took care of most of the coding, but having a part in completing a game with Python did wonders for my ego.

The gw0rp you will see this year is not like the gw0rp I described earlier in this post. “Old gw0rp” was a fairly unoriginal SketchFighter-like game. “New gw0rp” shares many qualities with “old gw0rp,” but is much more interesting, and much more worthy of the name “gw0rp.”

Now you have my background, and I can start writing real posts.

Comment on this post on my web site.

 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
Posted: 04 December 2008 08:59 PM   [ Ignore ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

Current Team
Project lead, programming, design, some art: Stephen Johnson
Sound and music: David J. Weiner of Atomicon
Design/content assistance: Calvin Eiber, Dan Hrovat
Art: Calvin Eiber

With the exception of David, we are all students at Case Western Reserve University.

Download the current version
Download the level editor

Old, basically accurate design document
gw0rp on github
Web site
Post comments here

Tools:
Adobe Illustrator, Photoshop
Audacity
Gimp
Git
Sfxr
SolidWorks
Stone Create
TextMate

Libraries:
Pyglet
Pymunk
PyYAML
Psyco
Lepton

 Signature 

Steve, Asleep: Wake me when it’s time to go.

Profile
 
 
   
9 of 9
9