8 of 9
8
“Gw0rp” Developer Diary by Stephen Johnson (diordna)
Posted: 16 December 2008 09:04 AM   [ Ignore ]   [ # 106 ]
Newbie
Avatar
Rank
Total Posts:  17
Joined  2008-12-10

Those graphics look pretty damn good :)

Profile
 
 
Posted: 16 December 2008 06:52 AM   [ Ignore ]   [ # 107 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

Calvin has started to generate some graphics for the units to replace the current prototype art. I’ll be putting in the new graphics some time today where I can.

Image Attachments
gw0rp_brain.jpggw0rp_thrust.jpg
 Signature 

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

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

I just added a title screen with graphical instructions. Instructions.txt has been replaced with Information.txt, since text-based instructions are no longer necessary.

I fixed the sound bug a while ago but forgot to mention it here.

The download link now lives in the first post of the dev diary, or on the entry page. I have changed servers; the new one should be faster.

 Signature 

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

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

Okay, so I lied about this new build’s features – don’t worry, I have a good reason.

When I first started designing gw0rp, I wanted it to be fun, but relatively difficult compared to “similar” games. I originally didn’t want players to be able to detach pieces at all without getting them shot off. I also wanted the only mechanism for attaching and adjusting pieces to be detaching and bumping into them. Feedback from the first couple of builds has told me that the game would be too hard if I didn’t allow for some leeway in the adjustment department.

Since my last post, I have tweaked the pause screen to allow players to rotate units by clicking and dragging. I hope that the game balances better now.

Download

 Signature 

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

Profile
 
 
Posted: 14 December 2008 03:32 PM   [ Ignore ]   [ # 110 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

I just uploaded a new build at the same link. The only major change is the pause screen, which now lets you remap keys. I’m not completely happy with the interface at this point, but it it had a good development-time-to-usefulness ratio. Eventually, each key will have an X by it to delete.

The next build should have a title screen and some basic instructions.

Download

 Signature 

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

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

Multiple key assignment is almost working. All I need to do is add a couple of simple GUI elements.

This next version will still need you to read Instructions.txt, because I haven’t put in a title screen yet. The build after this one will have on-screen instructions at launch.

 Signature 

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

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

A demo! A demo!

I spent a few minutes tweaking setup.py and my directory structure and came up with a build that should work. It’s a simple demonstration of my work on the physics so far.

Known issues:
-The input interface sucks. Nothing is labeled.
-Sound doesn’t work sometimes.

Download

Today, I spent most of my coding time on a soon-to-be code analysis tool called pyflow. Some friends and I just finished a course about compilers, and one of us decided that it might be fun to port the final project (which is next to useless) to Python/PLY and improve it from there. Until today, it would just parse a C file and generate an abstract syntax tree. Today, I added a module that would generate a graphviz .dot file from the AST so that it could be visualized neatly. Tim and I were giggling like little girls.

I uploaded an example source file and the corresponding graph as a PDF. The example file is meant to control a PIC microprocessor to make it to stupid things with LEDs, so the printf statements don’t really “printf,” but you get the idea.

 Signature 

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

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

I just got simple key selection working. I don’t yet have a mechanism for assigning multiple keys to a component, which is necessary for a reasonable control scheme, but I have enough for a demo.

Unfortunately, I’m out of time for tonight, so try back tomorrow.

 Signature 

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

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

Today I added the ability to remove objects from the ship. It took me a while to get the angles and velocities right, but now it’s working great. Next on the list is asking the player what key to assign. When I finish that, I’ll put together a build that people will be able to run without installing four separate modules.

I created a thread on the iDevGames forum to hold comments. You should post there instead of here.

Comment thread

 Signature 

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

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

Making a Katamari Ship in Chipmunk
Chipmunk Physics really isn’t built for modifying bodies and shapes on the fly, but it works well enough. Here are the steps I use to make two things stick together. I will refer to two objects, Big and Little, each with a body. The big body has many “units” and the little body has only one which is centered at the little body’s center of mass. Each unit has one circular shape and other game-related functions like thrusting and shooting. All of these steps happen within the big body, so it will be referred to as “self.”

1. In the collision callback function, store the wrapper object in a list to be processed in the big object’s next update, otherwise risk a segfault.

2. Chipmunk seems to ignore the effects of colliding when this removal business happens, so calculate the new velocity vector of the big object based on the vectors and masses of both objects. I would do the same for angular velocity, but I don’t know how to do that, and it’s not that noticeable anyway.

For the physics-challenged among you:

vx_new = (m1*vx1+m2*vx2)/(m1+m2)
vy_new = (m1*vy1+m2*vy2)/(m1+m2

3. Get the offset of the new shape with

big.body.world_to_local(little.body.position

4. Name a new variable to avoid confusion:

new_unit little.unit 

5. Remove the little body and its unit’s associated shape from the pymunk space. Also remove the little object from any game-related thingies.

space.remove(little.body)
space.remove(little.unit.shape)
object_update_list.remove(little

6. Add the new unit to the big object’s list of units. Give the unit a new shape associated with the big object’s body. Set its offset to what you got in step 3. Set its angle to the big object’s rotation added to the unit’s existing rotation to account for the fact that it will now be drawn with its rotation relative to the big object’s rotation. Add the new shape to the pymunk space. (I would show the code for this, but it’s all specific to gw0rp and therefore not pertinent to this guide.)

7. Update the center of mass of the big object (see below, it’s complicated).

8. Set the velocity of the big object’s body to what you got in step 2.

Updating the Center of Mass of a Katamari Object
In simple terms, it goes like this:
-Calculate the new center of mass. If you can’t do this, go back to high school physics. In gw0rp, it’s easy, because all masses are circular and have the same mass, so I can just average them. The new center of mass is at V1 relative to the old one.
-Also calculate the total mass and inertia. Just a sum of parts. the pymunk.moment_for_circle() function is my good friend here.
-Since the new center of mass is relative to the old center of mass, you can just subtract V1 from each offset to move it to the right place.
-Translate V1 to world coordinates and move the body there.

Unfortunately, it’s not that easy. In reality:
1. Calculate the new center of mass. Store a vector for the body’s new position:

new_body_position self.body.local_to_world((new_com_x,new_com_y)) 

2. Remove all the body’s shapes from the pymunk space.
3. Store the object’s body as the “old body” for later copying
4. Remove the “old body” from the pymunk space
5. Create a new body with all the same attributes as the old one, except with position new_body_position.
6. Add the new body to the space.
7. Create new shapes with all the same attributes as the old shapes, except with the new center of mass position subtracted from the old offset. Add the shapes to the pymunk space.

I noticed today that there is a possible memory leak: when objects are stuck together, the old sprite object might persist. But I don’t care, since that doesn’t happen very often, relatively speaking, and I can clear all the lists between levels anyway.

In local news, my electric toothbrush has stopped working.

 Signature 

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

Profile
 
 
Posted: 09 December 2008 03:48 PM   [ Ignore ]   [ # 116 ]
Member
RankRankRank
Total Posts:  56
Joined  2008-11-03

I must say this game looks pretty cool.

Good luck in the contest.

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

It’s pretty bizarre that physics.py even compiled for me. I just committed a fix. Thanks for testing – I didn’t think anyone would try it so soon.

Edit: Always delete your .pyc files…

 Signature 

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

Profile
 
 
Posted: 09 December 2008 10:50 AM   [ Ignore ]   [ # 118 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

I made my subversion repository public. Check out the game/ directory and run gw0rp.py to see how I’m doing.

Requirements to run build from svn:
Py-Lepton
Pymunk
Pyglet
Psyco

In the current build, you can move the ship with Left and Right. If you run into the free-floating thruster while holding Shift, it will attach to your ship and you can fire it with Down. (User-configurable controls coming soon.)

 Signature 

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

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

Working on getting things to stick together upon collision. It’s harder than I expected, for reasons I didn’t expect: memory management.

Update from precisely 15 minutes later:
I tweaked my approach and fixed a minor bug in my center of mass-adjusting code, and now you can stick things together just fine. I keep getting tracebacks from within pymunk that I can’t fix, but all the positions and angles are kosher. It doesn’t account for momentum loss yet, but I think the engine is now good enough to start making some actual gameplay.

 Signature 

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

Profile
 
 
Posted: 08 December 2008 10:47 AM   [ Ignore ]   [ # 120 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  123
Joined  2008-11-09

Last night I implemented the internal key binding system. Since I’m using Python, it took about ten minutes. Now in the main game class I can write:

self.bind_key(keyunit

and when you press the key, that unit will “activate” – thrust, shoot, etc.

But I didn’t really post here to mention that. I wanted to post a link to my last.fm profile so you can see what my coding music is.

 Signature 

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

Profile
 
 
   
8 of 9
8