Black Rock Games
A one man team from Marquette, MI. This is my first time entering into PyWeek. Best of luck to everyone this week.
Awards
Diary Entries
Test of Concept
It's 2 am Tuesday Morning over here in Michigan, and I am finishing up a test of concept program. I am writing a 2D, top down, tile based, puzzle game. So far I have a tile background, and 5 different objects that take up space on the grid (The player, walls, and three mob sprites, each of which moves differently) Hopefully after a little more work, and a good night's rest, I'll have my first upload posted.
Already I have started to notice the quirks of tile based games. Because sprites take up a single tile, and then abruptly shift into the next tile over, collisions arnt detected until both objects are sitting in the same space. This causes a quick flash as the sprite in question collides with a solid object and then a frame later moves back to it's previous position. Even at the highest of frame rates, its impossible not to notice. The other thing (so far) is that because all sprites move at the same time, its actually possible to "dodge" an unfriendly sprite as the two of you switch places. I think that offsetting the move time of the player and the other sprites by a single frame should fix this without it looking really bad, but I haven't had the time just yet to work that out.
Ok, time for some sleep, and hopefully I can remember how to package this all up.
Already I have started to notice the quirks of tile based games. Because sprites take up a single tile, and then abruptly shift into the next tile over, collisions arnt detected until both objects are sitting in the same space. This causes a quick flash as the sprite in question collides with a solid object and then a frame later moves back to it's previous position. Even at the highest of frame rates, its impossible not to notice. The other thing (so far) is that because all sprites move at the same time, its actually possible to "dodge" an unfriendly sprite as the two of you switch places. I think that offsetting the move time of the player and the other sprites by a single frame should fix this without it looking really bad, but I haven't had the time just yet to work that out.
Ok, time for some sleep, and hopefully I can remember how to package this all up.
Please help me work out this bug!!!
It's 10:20 am Michigan time. I got up early to see if I could get a working version of my game up, and ran into a rather intresting (quickly reaching frustrating level) error in some of my mob sprite code. Please take a look and see if you can find anything wrong. The sprite is supose to turn right anytime it reaches the screen edge or if it collides with a wall sprite. The code for keeping it on the screen works perfectly, and is shown below.
def update(self, time):
if time == 5:
self.lastx = self.positionx
self.lasty = self.positiony
self.positionx += self.dx
self.positiony += self.dy
if self.positionx > 589:
self.positionx = 589
self.dy = self.dx
self.dx = 0
self.direction = "Down"
if self.positionx < 1:
self.positionx = 1
self.dy = self.dx
self.dx = 0
self.direction = "Up"
if self.positiony > 379:
self.positiony = 379
self.dx = self.dy * -1
self.dy = 0
self.direction = "Left"
if self.positiony < 1:
self.positiony = 1
self.dx = self.dy * -1
self.dy = 0
self.direction = "Right"
self.rect.topleft = (self.positionx, self.positiony)
There there is the wall collide function, which sorts things out after the sprite hits a wall. Even though the following code is almost an exact copy of that above which does work, whenever a sprite hits a wall while traveling left or right on the screen, it bounces back the way it came.
def WallCollide(self):
self.positionx = self.lastx
self.positiony = self.lasty
if self.direction == "Right":
self.dy = self.dx
self.dx = 0
self.direction = "Down"
if self.direction == "Left":
self.dy = self.dx
self.dx = 0
self.direction = "Up"
if self.direction == "Down":
self.dx = self.dy * -1
self.dy = 0
self.direction = "Left"
if self.direction == "Up":
self.dx = self.dy * -1
self.dy = 0
self.direction = "Right"
For the life of me, I can not think of a single reason why two nearly identical code sections should produce two very different (one of which is highly undesirable) results. Any help with sorting this out would be appreciated. Thanks in advance.
def update(self, time):
if time == 5:
self.lastx = self.positionx
self.lasty = self.positiony
self.positionx += self.dx
self.positiony += self.dy
if self.positionx > 589:
self.positionx = 589
self.dy = self.dx
self.dx = 0
self.direction = "Down"
if self.positionx < 1:
self.positionx = 1
self.dy = self.dx
self.dx = 0
self.direction = "Up"
if self.positiony > 379:
self.positiony = 379
self.dx = self.dy * -1
self.dy = 0
self.direction = "Left"
if self.positiony < 1:
self.positiony = 1
self.dx = self.dy * -1
self.dy = 0
self.direction = "Right"
self.rect.topleft = (self.positionx, self.positiony)
There there is the wall collide function, which sorts things out after the sprite hits a wall. Even though the following code is almost an exact copy of that above which does work, whenever a sprite hits a wall while traveling left or right on the screen, it bounces back the way it came.
def WallCollide(self):
self.positionx = self.lastx
self.positiony = self.lasty
if self.direction == "Right":
self.dy = self.dx
self.dx = 0
self.direction = "Down"
if self.direction == "Left":
self.dy = self.dx
self.dx = 0
self.direction = "Up"
if self.direction == "Down":
self.dx = self.dy * -1
self.dy = 0
self.direction = "Left"
if self.direction == "Up":
self.dx = self.dy * -1
self.dy = 0
self.direction = "Right"
For the life of me, I can not think of a single reason why two nearly identical code sections should produce two very different (one of which is highly undesirable) results. Any help with sorting this out would be appreciated. Thanks in advance.