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! / mouse control side scroll?

Author
Message
blank
19
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 30th Mar 2003 17:08
hi,
im going to make a mouse controlled side scroller like simon the sorcerer.
to do this i think the code shol;d be sumthing like:
if mouseclick()=1
x=x+1 if x=mousex() then x=x+0
if x>600 then (move camera or something so that character on other side and next part of level revealed)
I need to now how to do the thing in brackets. and the thingy about mouse movement.
Thanks
Stevo
20
Years of Service
User Offline
Joined: 4th Oct 2002
Location:
Posted: 3rd Apr 2003 22:53
Hi Cartoon Monkey
Right first you need to set up some bitmaps, you have to have something to scroll to! What you actually do when scrolling is move the background. Make two bitmaps, (microsoft paint will do), make them 640*480. Then go

load bitmap "Your filename.bmp",1
get image 11,0,0,639,479
delete bitmap 1
you don't need the bitmap once you've got the image

load bitmap "Your filename.bmp",2
get image 12,0,0,639,479
delete bitmap 2


rem setup variables
these are for positioning the images
xpos = 640
ypos = 0

rem this makes sure it updates at the end of each loop
rem and stops your program from being jumpy
sync on
sync
do
cls

make sure all images especially background ones are tied
to the xpos and ypos values, because it is those which you change

paste image 11,xpos-640,ypos
paste image 12,xpos,ypos


rem this changes the xpos
if leftkey()=1
xpos=xpos-1
rem this is how you stop the background picture just going right
rem off your screen
if xpos =< 0
xpos=0
endif

if rightkey()=1
xpos=xpos+1
rem this is how you stop the background picture just going right
rem off your screen
if xpos =>640
xpos=640
endif

rem the mouse bit
with the mouse detect the actual screen edge and then when your mouse cursor
is at the edge you just put the same code again as for the arrow keys

if mousex()=> 638
xpos=xpos+1
if xpos => 640
xpos=640
endif

if mousex()=< 2
xpos=xpos-1
if xpos =< 0
xpos=0
endif

sync
loop

for things like the brackets on mousex() you don't have to put anything, but when you do other things with brackets then you have to put in the values
you want



anyways this should work if it doesn't the + & - might be the wrong way around

blank
19
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 5th Apr 2003 16:21
thanks stevo! x-d

Login to post a reply

Server time is: 2023-01-27 02:19:07
Your offset time is: 2023-01-27 02:19:07