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! / Sprites

Author
Message
BJS2
22
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 8th Jun 2004 16:37
I have two diferent bitmap one of a person walking left and one walking right

When I press left on the key board he walks left
When I press right on the key board he walks left
BJS2
22
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 8th Jun 2004 16:38
Code
BJS2
22
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 8th Jun 2004 16:38
Code 2

depth=32
set display mode 1024,768,depth
hide mouse
ink rgb(o,214,o),1
Print "LOADING"

LOAD bitmap "runner.bmp",1
FOR y=0 to 1
FOR x=0 to 6
GET IMAGE 1+x+(y*7),(x*89),(y*120),(x*89)+89,(y*120)+120
NEXT x
NEXT y
delete bitmap 1


LOAD bitmap "runner 2.bmp",2
FOR y=0 to 1
FOR x=0 to 6
GET IMAGE 2+x+(y*7),(x*89),(y*120),(x*89)+89,(y*120)+120
NEXT x
NEXT y
delete bitmap 2



load image "Ground Dirt.bmp",3


load image "Images\Screens\Gore.bmp",80
load image "Images\Screens\Delete.bmp",82
load image "Images\Screens\Exit.bmp",83
load image "Images\Screens\Join.bmp",84
load image "Images\Screens\Graphics.bmp",85
load image "Images\Screens\Credit.bmp",86
load image "Images\Screens\Control.bmp",87
load image "Images\Screens\Audio.bmp",88
load image "Images\Screens\Game.bmp",89
load image "Images\Screens\Load.bmp",90
load image "Images\Screens\Multiplayer.bmp",91
load image "Images\Screens\New Game.bmp",92
load image "Images\Screens\Options.bmp",93
load image "Images\Screens\Player Skin.bmp",94
load image "Images\Screens\Save.bmp",95
load image "Images\Screens\Start.bmp",96



LOAD music "Sound\Music\Song 1.mp3",1
LOAD music "Sound\Music\Song 2.mp3",2
LOAD music "Sound\Music\Song 3.mp3",3
LOAD music "Sound\Music\Song 4.mp3",4
LOAD music "Sound\Music\Main.mp3",5



load sound "radioadjust.wav",1
load sound "G explosion.wav",2
load sound "weapon fire.wav",3
load sound "thor-hit1.wav",4
load sound "thor-at2.wav",5
load sound "thor-death.wav",6
load sound "thor-idle.wav",7


rem Set player variables
xpos=370
ypos=500
image=1


Print "LOADED"
rem wait 2000
cls

show mouse
play music 5

rem Menu
paste image 80,300,75
paste image 92,0,400
paste image 90,0,440
paste image 91,0,480
paste image 93,0,520
paste image 83,0,560




rem Activate manual syncronization
SYNC

suspend for key
cls
stop music 5
play music 2



skip:

startofprogram:

do
if inkey$()="q"
gosub song1:
endif

if inkey$()="w"
gosub song2:
endif

if inkey$()="e"
gosub song3:
endif


if inkey$()="r"
gosub song4:
endif


if mouseclick()=0
goto secondstartofprogram
endif
loop
secondstartofprogram:
do


if rightkey()=1
gosub rightkey
endif

if leftkey()=1
gosub leftkey
endif

if mouseclick()=0
goto startofprogram
endif



loop


rightkey:
image=image+1 : IF image>12 THEN image=2
sprite 1,xpos,ypos,image
print "right"
cls
goto startofprogram



leftkey:
image=image+1 : IF image>12 THEN image=2
sprite 2,xpos,ypos,image
print "left"
cls
goto startofprogram





























Song1:
stop music 2
stop music 3
stop music 4
loop music 1
goto secondstartofprogram

song2:
stop music 1
stop music 3
stop music 4
loop music 2
goto secondstartofprogram

song3:
stop music 1
stop music 2
stop music 4
loop music 3
goto secondstartofprogram


song4:
stop music 1
stop music 2
stop music 3
loop music 4
goto secondstartofprogram
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Jun 2004 17:52
So he walks left all of the time?

Cos your left subroutine looks exactly the same as your right subroutine.

Is that what you are wanting?, because your question is cleverly hidden.

JHA
22
Years of Service
User Offline
Joined: 30th Dec 2003
Location: Massachusetts, USA
Posted: 8th Jun 2004 20:34 Edited at: 8th Jun 2004 20:41
Quote: "
LOAD bitmap "runner.bmp",1
FOR y=0 to 1
FOR x=0 to 6
GET IMAGE 1+x+(y*7),(x*89),(y*120),(x*89)+89,(y*120)+120
NEXT x
NEXT y
delete bitmap 1


LOAD bitmap "runner 2.bmp",2
FOR y=0 to 1
FOR x=0 to 6
GET IMAGE 2+x+(y*7),(x*89),(y*120),(x*89)+89,(y*120)+120
NEXT x
NEXT y
delete bitmap 2
"


Looks to me like the problem is here. You are grabbing images 1 to 14 in the first stage and then grabbing images 2 to 15 in the second.

You are effectively overwriting images 2 to 14 from the first sequence, with the images from the second sequence.

Try this:



This way, the first sequence uses images from 1 to 14 and since we do not reset the newImage variable, it continues from 15 to 28.

Now in the rightkey: and leftkey: sections, you would do this:



Thinking about this a little more, this might not be exactly right, but I'm out of time and have to go. This should get you closer to the goal anyway.

Please let me know if it helps.

[Edit]
Doesn't look like you set the sprite up using the Sprite command. You may need to do this, if you are getting an error about the sprite not existing.

For that matter, what are you seeing?
[/Edit]

Thank you
JHA

Login to post a reply

Server time is: 2026-06-09 13:55:52
Your offset time is: 2026-06-09 13:55:52