Add Moving Chipmunk

Create six sprites

Six Sprite Properties
Sprite Name File Image Size
spr_chip_move_up chipmunk_move_up.png 200 x 40
spr_chip_move_down chipmunk_move_down.png 160 x 40
spr_chip_move_left chipmunk_move_left.png 160 x 40
spr_chip_move_right chipmunk_move_right.png 160 x 40
spr_chip_stand_front chipmunk_stand_front.png 40 x 40
spr_chip_stand_back chipmunk_stand_back.png 40 x 40
spr_fence fence.png 40 x 40

Create Objects

Create object properties
Object Title Object Sprite
obj_chip_move_up spr_chip_move_up
obj_chip_move_down

spr_chip_move_down

obj_chip_move_left spr_chip_move_left
obj_chip_move_right spr_chip_move_right
obj_chip_stand_front spr_chip_stand_front
obj_chip_stand_back spr_chip_stand_back
obj_fence spr_fence

Object Properties

obj_fence

Solid = checked > OK

fence

obj_chip_stand_front

Parent = obj_fence

stand front properties

Move Left

Actions
Screen capture
Add Event > Key Press > Left
key left
Control tab > Check Grid check grid > Applies to = Self, snap hor = 40, snap vert = 40, NOT = checked > OK
check grid
Control tab > Exit Event exit event
exit event
Control tab > Check Object check object > Applies to = Self, object = obj_fence, x = -40, y = 0, Relative = checked, NOT = checked > OK
check object
Control tab > Start block start block
Move tab > Move Fixed move fixed > Applies to = Self, Direction =Left, Speed = 5 > OK
move direction
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_move_left, subimage = -1, speed = 1 > OK
change sprite
Control tab > End Block stop block
Control tab > Else icon else
Control tab > Start Block start block
Move tab > Move Fixed move fixed > Applies to = Self, Direction = Center, Speed = 0 > OK
no move
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_stand_front, subimage = -1, speed = 1 > OK
change sprite
Control tab > End Block stop block

Move Right (same steps as Move Left with minor changes, screen capture show differences)

Actions
Screen Capture
Add Event > Key Press > Right
move right
Control tab > Check Grid check grid > Applies to = Self, snap hor = 40, snap vert = 40, NOT = checked > OK
Control tab > Exit Event exit event
Control tab > Check Object check object > Applies to = Self, object = obj_fence, x = 40, y = 0, Relative = checked, NOT = checked > OK
check object
Control tab > Start block start block
Move tab > Move Fixed move fixed > Applies to = Self, Direction =Right, Speed = 5 > OK
moving right
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_move_right, subimage = -1, speed = 1 > OK
change sprite
Control tab > End Block stop block
Control tab > Else icon else
Control tab > Start Block start block
Move tab > Move Fixed move fixed > Applies to = Self, Direction = Center, Speed = 0 > OK
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_stand_front, subimage = -1, speed = 1 > OK
Control tab > End Block stop block

Move Up (same steps as Move Left with minor changes, screen capture show differences)

Actions
Screen Capture
Add Event > Key Press > Up
move up
Control tab > Check Grid check grid > Applies to = Self, snap hor = 40, snap vert = 40, NOT = checked > OK
Control tab > Exit Event exit event  

Control tab > Check Object check object > Applies to = Self, object = obj_fence, x = 0, y = -40, Relative = checked, NOT = checked > OK

Note: Y increases as you move down the screen. As we are moving up screen Y will decrease.

check object
Control tab > Start block start block  
Move tab > Move Fixed move fixed > Applies to = Self, Direction =Up, Speed = 5 > OK move fixed up
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_move_up, subimage = -1, speed = 1 > OK change sprite move up
Control tab > End Block stop block  
Control tab > Else icon else  
Control tab > Start Block start block  
Move tab > Move Fixed move fixed > Applies to = Self, Direction = Center, Speed = 0 > OK  
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_stand_front, subimage = -1, speed = 1 > OK  
Control tab > End Block stop block  

Move Down (same steps as Move Left with minor changes, screen capture show differences)

Actions
Screen Capture
Add Event > Key Press > Down
move down
Control tab > Check Grid check grid > Applies to = Self, snap hor = 40, snap vert = 40, NOT = checked > OK
Control tab > Exit Event exit event

Control tab > Check Object check object > Applies to = Self, object = obj_fence, x = 0, y = 40, Relative = checked, NOT = checked > OK

Note: Y increases as you move down the screen.

check object
Control tab > Start block start block
Move tab > Move Fixed move fixed > Applies to = Self, Direction =Up, Speed = 5 > OK
move down
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_move_down, subimage = -1, speed = 1 > OK
change into move down
Control tab > End Block stop block
Control tab > Else icon else
Control tab > Start Block start block
Move tab > Move Fixed move fixed > Applies to = Self, Direction = Center, Speed = 0 > OK
Main1 tab > Change Sprite change sprite > Applies to = Self, Sprint = spr_chip_stand_front, subimage = -1, speed = 1 > OK
Control tab > End Block stop block

Test Movement

This is a good place to test the movement of your chipmunk.

Open Room room_level_one & insert one obj_chip_stand_front.

Save & exit room_level_one

save room

Save your GameMaker files

save game

Run Game

run game

To How To