Posted: 27th May 2008 17:51
@IanM
Please don't lock this.
@The Rest of the Forum
I'm trying to create a puzzle game where when the character moves the enemy moves in the opposite direction. There are trees which the goblin cannot pass through. The goal is to get the goblin trapped in against a tree so the player can come up behind it press the spacekey to swing his sword to destroy it.
Here is the code I've got:
cls rgb(125,0,125)
load image "Male Character.bmp", 1
sprite 1, sprite1x, sprite1y, 1
load image "Male Character Attack Motion.bmp", 4
sprite 7, sprite1x, sprite1y, 4
hide sprite 7
sprite1x = 150
sprite1y = 150
load image "Goblin Enemy.bmp", 2
sprite 2, sprite2x, sprite2y, 2
sprite2x = 300
sprite2y = 300
load image "Tree (Rough).bmp", 3
sprite 3, tree1x, tree1y, 3
sprite 4, tree2x, tree2y, 3
sprite 5, tree3x, tree3y, 3
sprite 6, tree4x, tree4y, 3
tree1x = 100
tree1y = 100
tree2x = 200
tree2y = 100
tree3x = 400
tree3y = 200
tree4x = 100
tree4y = 400
main:
do
sprite 1, sprite1x, sprite1y, 1
sprite 7, sprite1x, sprite1y, 4
sprite 2, sprite2x, sprite2y, 2
sprite 3, tree1x, tree1y, 3
sprite 4, tree2x, tree2y, 3
sprite 5, tree3x, tree3y, 3
sprite 6, tree4x, tree4y, 3
if 1 = upkey() then sprite1y = sprite1y -10
if 1 = downkey() then sprite1y = sprite1y +10
if 1 = leftkey() then sprite1x = sprite1x -10
if 1 = rightkey() then sprite1x = sprite1x +10
if 1 = spacekey() then gosub playerattack
if 1 = upkey() then sprite2y = sprite2y +10
if 1 = downkey() then sprite2y = sprite2y - 10
if 1 = leftkey() then sprite2x = sprite2x +10
if 1 = rightkey() then sprite2x = sprite2x -10
if sprite collision(2,3) = 1 then sprite2x = sprite2x - 10
if sprite collision(2,4) = 1 then sprite2x = sprite2x +10
if sprite collision(2,5) = 1 then sprite2y = sprite2y - 10
if sprite collision(2,6) = 1 then sprite2y = sprite2y +10
loop
playerattack:
hide sprite 1
show sprite 7
wait 250
if sprite collision(7,2) = 1
wait 250
hide sprite 7
show sprite 1
end
endif
hide sprite 7
show sprite 1
gosub main
Here are the sprites:
Attachments
Login to view attachments