I sorted out all the control problems, and in the process a few extra functions and a key-mapper
There is now a:
Loaddkeys() function for loading your keymap from a file
Runkeys() for detection purposes, called once a loop
KeyDown() for detecting if a user had just pressed a key (only occurs at the instant a key is pressed).
So it makes input easy cos you can now have a versatile control system that you can have the user configure, and you can detect presses and taps! So here’s the tutorial code:
sync on
hide mouse
autocam off
Dim KeystateA(255,1)
Dim Keys(255)
LoadKeys()
color backdrop rgb(255,255,255)
do
cls
set cursor 1,1
print "Currently Pressing: " + str$(scancode())
for I=0 to 30
if keydown(I)
ink RGB(255,0,0),rgb(255,255,255)
else
ink RGB(0,0,0),rgb(255,255,255)
endif
if keystate(Keys(I))=1 then ink RGB(0,0,255),rgb(255,255,255)
print Keys(I)
next I
RunKeys()
sync
loop
Function Keydown(Code)
kd#=0
scode=keys(code)
if keystate(scode)=1
if keystateA(code,0)=0
keystateA(code,0)=1
kd#=1
endif
endif
EndFunction kd#
Function RunKeys()
For I=0 to 255
scode=keys(I)
if keystate(scode)=0
if keystateA(I,0)=1
keystateA(I,0)=0
endif
endif
next I
endfunction
Function LoadKeys()
f$="keys.txt"
open to read 1,f$
c=0
do
Read string 1,t$
if mid$(t$,1)="/" then goto e:
if c<0 then c=0
keys(C)=val(t$)
c=c+1
e:
if file end(1) then exit
loop
close file 1
endfunction
And the keys.txt key map file (put it in the same directory as your project):
// 0 Up Key
200
//1 Down Key
208
//2 Left Key
203
// 3 Right Key
205
// 4 W(up) Key
17
// 5 S(sown) Key
31
// 6 A(left) Key
30
// 7 D(right) Key
32
// ------- End movement keys --------
// Begin Weapon Welect Keys (1-9,0)
2
3
4
5
6
7
8
9
10
11
//------- End Weapon Welect Keys --------
//Begin misc keys
// 18 G - Grab Screenshot key
34
// 19 Escape Key
27
// 20 M (Map Key)
50
Feel free to use it in any project you fancy if you like it, but make sure you gove me a mention
Now Raven, I’ve been investigating these static objects, but I cant just remove them at the mo for two reasons:
1. My game will slow down so much it will be unbearable
2. The collision system wont work
But I’ll have a go later in the week and see what I can do, cos if it can’t work for everybody, its no good at all.
P.S. if you have a nice floor texture handy, then please email it me and I’ll put it in, (and put you on the credits.)