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.

Newcomers DBPro Corner / need help on enemy movement

Author
Message
Brock
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: USA,MI,Detroit,
Posted: 16th Oct 2004 08:26
can any one tell me a pathfinding code or romdom code i know some tell me what wrong with this code wh dont it move monster sprite

`Load Player Image as Image #1
load image "sprites/Player.bmp",1

`Load Enemies as Image #10
load image "sprites/monster.bmp",2


`Position the player
playerX = 80
playerY = 300

`Position the enemy
monsterX = 250
monsterY = 300
`===================================================
`-----------------------------------------------------
`-----------------M_A_I_N--L_O_O_P--------------------
`-----------------------------------------------------
do
`The following lines below implement the Controls stated on the

sprite 1,playerX,playerY,1
sprite 2,monsterX,monsterY,2

`Moves the Player to the left
if leftkey() = 1 then playerX = playerX - 3

`Moves the Player to the Right
if rightkey() = 1 then playerX = playerX + 3

`Moves the Player to the up
if upkey() = 1 then playery = playery - 3

`Moves the Player to the Right
if downkey() = 1 then playery = playery + 3


MOVE SPRITE 1,2


sync
loop


`**************************************************************************************************
` END MAIN LOOP
`**************************************************************************************************

` End the program

Chima-Duru
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 16th Oct 2004 13:11 Edited at: 16th Oct 2004 13:23
Quote: "wh dont it move monster sprite"
There is nothing in your code to move the monster sprite. You are moving the player with the arrow keys and with the move sprite command. Is it possible you meant to use MOVE SPRITE 2,2 instead of MOVE SPRITE 1,2 ?

[edit] also put the sprite command for the monster sprite before the main loop or it will keep putting it back at the same position.


The pathfinding and random code will depend on how you decide to do your levels and collision. There are many ways to do this and they all depend on other things that you use in your code.

A basic moving back and forth code would be something like this.


Login to post a reply

Server time is: 2024-11-27 12:27:52
Your offset time is: 2024-11-27 12:27:52