I’ve been trying to complete Game of Coins Step 1 in Game Development 2 and I think I’ve got the code right but my hero isn’t moving.
I’ve added all of the maze objects (forest squares, coins, mushrooms) and they display ok when I run the code. The problem is that when I try to move my hero (WASD or mouse) he doesn’t actually move, he just turns to face the appropriate way for the key that’s being pressed but stays in the same location at the bottom-left of the maze.
# Let's start building a new Pac-Man style arcade game.
# We will continue working on this game in the next levels.
# First we need the forest.
# Let's spawn some "forest" tiles in a grid pattern.
game.spawnXY("forest", 16, 16)
game.spawnXY("forest", 32, 16)
game.spawnXY("forest", 48, 16)
game.spawnXY("forest", 64, 16)
game.spawnXY("forest", 16, 32)
game.spawnXY("forest", 32, 32)
game.spawnXY("forest", 48, 32)
game.spawnXY("forest", 64, 32)
game.spawnXY("forest", 16, 48)
# As you can see the distance between them is 16 meters.
# Spawn more forest tiles in the three spots
# where they are missing
game.spawnXY("forest", 48, 48)
game.spawnXY("forest", 64, 48)
game.spawnXY("forest", 32, 48)
# Next we spawn coins in between the forests.
# Leave free space for mushroom power-ups!
# Scroll down, there are many coins.
game.spawnXY("bronze-coin", 16, 8)
game.spawnXY("bronze-coin", 24, 8)
game.spawnXY("bronze-coin", 32, 8)
game.spawnXY("bronze-coin", 48, 8)
game.spawnXY("bronze-coin", 56, 8)
game.spawnXY("bronze-coin", 64, 8)
game.spawnXY("bronze-coin", 72, 8)
game.spawnXY("bronze-coin", 8, 16)
game.spawnXY("bronze-coin", 24, 16)
game.spawnXY("bronze-coin", 40, 16)
game.spawnXY("bronze-coin", 56, 16)
game.spawnXY("bronze-coin", 72, 16)
game.spawnXY("bronze-coin", 8, 24)
game.spawnXY("bronze-coin", 16, 24)
game.spawnXY("bronze-coin", 24, 24)
game.spawnXY("bronze-coin", 32, 24)
game.spawnXY("bronze-coin", 40, 24)
game.spawnXY("bronze-coin", 48, 24)
game.spawnXY("bronze-coin", 56, 24)
game.spawnXY("bronze-coin", 64, 24)
game.spawnXY("bronze-coin", 72, 24)
game.spawnXY("bronze-coin", 24, 32)
game.spawnXY("bronze-coin", 56, 32)
game.spawnXY("bronze-coin", 8, 40)
game.spawnXY("bronze-coin", 16, 40)
game.spawnXY("bronze-coin", 24, 40)
game.spawnXY("bronze-coin", 32, 40)
game.spawnXY("bronze-coin", 40, 40)
game.spawnXY("bronze-coin", 48, 40)
game.spawnXY("bronze-coin", 56, 40)
game.spawnXY("bronze-coin", 64, 40)
game.spawnXY("bronze-coin", 72, 40)
game.spawnXY("bronze-coin", 8, 48)
game.spawnXY("bronze-coin", 24, 48)
game.spawnXY("bronze-coin", 40, 48)
game.spawnXY("bronze-coin", 56, 48)
game.spawnXY("bronze-coin", 72, 48)
game.spawnXY("bronze-coin", 8, 56)
game.spawnXY("bronze-coin", 16, 56)
game.spawnXY("bronze-coin", 24, 56)
game.spawnXY("bronze-coin", 32, 56)
# Spawn more coins in the empty spaces. (8 meters apart)
game.spawnXY("bronze-coin", 40, 32)
game.spawnXY("bronze-coin", 40, 56)
game.spawnXY("bronze-coin", 48, 56)
game.spawnXY("bronze-coin", 56, 56)
game.spawnXY("bronze-coin", 64, 56)
game.spawnXY("bronze-coin", 72, 56)
game.spawnXY("bronze-coin", 72, 48)
game.spawnXY("bronze-coin", 72, 32)
# Mushrooms will be our powerups.
game.spawnXY("mushroom", 40, 8)
game.spawnXY("mushroom", 8, 32)
# Spawn more mushrooms.
game.spawnXY("mushroom", 36, 25)
game.spawnXY("mushroom", 17, 37)
# The player and goal setup.
player = game.spawnPlayerXY('knight', 8, 8)
player.maxSpeed = 30
game.addCollectGoal()
# Now test what you’ve done to make sure it works!
I’ve tried reloading the game but it still doesn’t work.
Any help would be appreciated.
Thanks!