Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Problem With Moving Enemy Sprite

Author
Message
iron programmer
15
Years of Service
User Offline
Joined: 10th May 2008
Location: payying taxz to mi keety? (paying taxes)
Posted: 11th May 2008 02:28
I can't get the enemy sprite to move in my game! Please help!
I need to get this game done in 14 days!

Here's the code:

sync on
sync rate 100

cls

hide mouse

load image "Male Character.bmp", 1
sprite 1, 100, 100, 1

load image "Goblin Enemy.bmp", 2
sprite 2, 500, 100, 2

load image "Enemy Destroy.bmp", 3
sprite 3, 500, 100, 3
hide sprite 3

load image "Male Character Attack Motion.bmp", 4

load sound "explode2.wav", 1

sprite2xpos = 500
sprite3xpos = 500

do
sync on
sync rate 100
cls
hide mouse
load image "Male Character.bmp", 1
sprite 1, 100, 100, 1
load image "Goblin Enemy.bmp", 2
sprite 2, 500, 100, 2
load image "Enemy Destroy.bmp", 3
sprite 3, 500, 100, 3
hide sprite 3
load image "Male Character Attack Motion.bmp", 4
load sound "explode2.wav", 1
sprite2xpos = 500
sprite3xpos = 500
sprite2xpos = xpos +10
sprite3xpos = xpos +10
if sprite collision(2, 1) then gosub deletedplayer
if sprite2xpos <0 then sprite2xpos = sprite2xpos - 500
if sprite3xpos <0 then sprite3xpos = sprite3xpos - 500
if 1 = upkey() then sprite 1, 100, 0, 1
if 1 = downkey() then sprite 1, 100, 200, 1
if 1 = spacekey() then gosub playerattack
loop

playerattack:
hide sprite 1
sprite 4, 100, 100, 4
wait 50
if 1 = sprite collision(4, 2) then gosub deletedenemy
delete sprite 4
show sprite 1

deletedenemy:
delete sprite 2
show sprite 3
play sound 1

deletedplayer:
play sound 1
end
iron programmer
15
Years of Service
User Offline
Joined: 10th May 2008
Location: payying taxz to mi keety? (paying taxes)
Posted: 11th May 2008 03:43
P.S. - I'm trying to get it to move to the player's left.
iron programmer
15
Years of Service
User Offline
Joined: 10th May 2008
Location: payying taxz to mi keety? (paying taxes)
Posted: 11th May 2008 17:50
Thanks.
ArK 48k
16
Years of Service
User Offline
Joined: 29th Jun 2007
Location:
Posted: 27th Jun 2008 18:39
Get rid of sync "rate/sync on" calls within your loop: just one "sync" before you type "loop". Also load images and music before your main loop otherwise you are overworking your valuable processing time.
I hope the following helps (I'm currently at work typing this so your going to have to fill in the gaps in the code.) all the best with your project.

[do
enemyxpos# = position sprite x(3) - 0.50
sprite 3,enemyxpos#,100,3

sync
loop]

Login to post a reply

Server time is: 2024-05-04 13:32:25
Your offset time is: 2024-05-04 13:32:25