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 / please please please help!!!!!!!!!!!!!!!!

Author
Message
Ashley computer freek
21
Years of Service
User Offline
Joined: 28th May 2003
Location:
Posted: 29th May 2003 11:16
have you ever played pokemon for the game boy do you know how i can make it so the person can walk around the screen without drawing loads of bitmaps of him in differant possitions
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 29th May 2003 13:18
In Pokemon the character generally stays in the centre of the screen. Here's how to move an image around the screen, however:

Some recommended setup, this makes a consistent framerate of 30fps

sync on
sync rate 30

First you need to load the image, using the LOAD IMAGE command:

load image "player.bmp",1

player.bmp is the name of a bitmap you'll need to have in the same folder as your code. It loads the image into image 1, this is the number you use to reference it later.

Then, make some variables to hold the position:

x=300
y=200

The next part will have to be enclosed in a do..loop so it continues running and allows user input.

do

Some user input, we're just going to move the image (known as a sprite) left and right using the arrowkeys, by changing the variables containing the position of the sprite whenever the arrowkeys are pressed.

if leftkey()=1 then x=x-1
if rightkey()=1 then x=x+1

Then we display the sprite. The SPRITE command takes four values, the number of the sprite, the x and y coordinates and the number of the image (we loaded image 1 above, so use that). Just to show that the sprite number doesn't have to be the same as the image number, I'm going to use sprite number 5.

sprite 5,x,y,1

Update the screen and end the loop

sync
loop

The whole program therefore is:



To do animation, you'll need to load several images, each with one frame of animation, using different image numbers, then change the image number that the sprite uses (the last value) each frame to cycle through the animation.

Once I was but the learner,
now, I am the Master.
Ashley computer freek
21
Years of Service
User Offline
Joined: 28th May 2003
Location:
Posted: 30th May 2003 14:29
thanks alot for the code and the info i will go and try it out

Login to post a reply

Server time is: 2024-11-24 16:21:17
Your offset time is: 2024-11-24 16:21:17