Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Game Movement
#1
So I'm back!

Here's my question this time.

If I want to move an object to the left on the screen I type like this:

IF press$ = "a" then x = x - 1

and up

IF press$ = "w" then y = y - 1

But what if I want to move it up, left holding down "a" and "w" at the same time, how do I do that?
Reply
#2
you cant that way. you need a mutikey handler
heres one
http://faq.qbasicnews.com/?blast=MiloSed...ardHandler
and heres another
http://forum.qbasicnews.com/viewtopic.php?t=5307
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#3
u don't need multi-keys, but thats preferable.....

Code:
'Map Movement

SUB Update.Map(plx as integer, ply as integer, mpx as integer, mpy as integer)

'MPX&MPY is top left coords of map

for smx = mpx to (mpx + Total_Screen_Tiles_X)
for smy = mpy to (mpy + Total_Screen_Tiles_Y)
  img=Map(smx,smy).tileindex
  put (smx-Xres,smy-yres), ImageArray(img)
next
next

END SUB
Reply
#4
A custom keyboard handler is preferable for any game, simply because they are a lot faster.

But if you don't want to use a CKH, you could assign keys for moving upperleft or so... (Q) Wink
Reply
#5
If u want fast keyboarding:
Code:
dim keys as LONG

do

'There is some code to clear keyboard buffer, but i don't know it off
'the top of my head

keys = INP(&H60)   'Get Keyboard Scan Code

if Keys = &H1  'ESC
exit do
end if

loop
end
Reply
#6
Code:
DEF SEG = &H40
POKE &H1A, PEEK(&H1C)
DEF SEG

i think
Reply
#7
It looks right.......i'd assume that werks......

Good Job, man~

Alex~
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)