I'm having a small problem getting a number saved to an array. What I want to happen is that if it is player one's turn then the keypresses get saved to the array keypresses(). Then when it is player two's turn I want it so that the keypresses are saved to the array keypresses2. My code isn't working and it is all getting saved to the first array.
This is my code:
REM Project: Campfire Chant
REM Created: 1/8/2008 10:16:56 PM
REM
REM ***** Main Source File *****
REM
sync on
cls 0
autocam off
position camera 0,0,10
point camera 0,0,0
load image "arrowtex.png",1
load image "arrowtex2.png",2
load image "arrowtex3.png",3
make object plain 50,20,3
position object 50,0,-.5,-2
`make walls
make object box 51,.1,3,1
position object 51,5,-.4,-1
color object 51,rgb(0,0,0)
make object box 52,.1,3,1
position object 52,2,-.4,-1
color object 52,rgb(0,0,0)
make object box 53,.1,3,1
position object 53,-1,-.4,-1
color object 53,rgb(0,0,0)
make object box 54,.1,3,1
position object 54,-4,-.4,-1
color object 54,rgb(0,0,0)
`make moving wall
make object box 56,.05,3,1
position object 56,8,-.4,-1
color object 56,rgb(255,255,0)
set object emissive 56,rgb(255,255,0)
`variables
objx = 9
objy = 0
movex# = 8
canpress = 1
arrow = 1
arrowslot = 1
objects = 0
presses = 2
round = 0
player = 1
`makes arrow to store keypresses
dim keypresses(10)
player1:
presses = presses + round
player = 1
do
`print variables
print objonline
print time
text 0,0,str$(keypresses(1))
text 0,10,str$(keypresses(2))
text 0,20,str$(keypresses(3))
text 0,30,str$(keypresses(4))
text 0,40,str$(keypresses(5))
text 0,50,str$(keypresses(6))
text 0,60,str$(keypresses(7))
text 0,70,str$(keypresses(8))
text 0,80,str$(keypresses(9))
text 0,90,str$(keypresses(10))
text 0,110,str$(presses)
text 0,120,str$(player)
`make up arrow
if upkey() = 1
if canpress = 1
arrow = arrow + 1
load object "arrow.x",arrow
objx = objx - 3
canpress = 0
objonline = objonline + 1
texture object arrow,1
set object emissive arrow,rgb(255,0,0)
keypresses(arrowslot) = 1
inc arrowslot
inc objects
dec presses
endif
endif
`make left arrow
if leftkey() = 1
if canpress = 1
arrow = arrow + 1
load object "arrow.x",arrow
zrotate object arrow, 270
objx = objx - 3
canpress = 0
objonline = objonline + 1
texture object arrow,2
set object emissive arrow,rgb(0,0,255)
keypresses(arrowslot) = 2
inc arrowslot
inc objects
dec presses
endif
endif
`make right arrow
if rightkey() = 1
if canpress = 1
arrow = arrow + 1
load object "arrow.x",arrow
zrotate object arrow, 90
objx = objx - 3
canpress = 0
objonline = objonline + 1
texture object arrow,3
set object emissive arrow,rgb(0,255,0)
keypresses(arrowslot) = 3
inc arrowslot
inc objects
dec presses
endif
endif
`positions arrows
if object exist(arrow)
scale object arrow, 20,20,20
position object arrow,objx,objy,0
endif
`checks whether or not to go to the next line
if objonline > 5
objy = -1
objx = 6
objonline = 0
endif
`checks for wall collision so you can add press arrows again and checks if you've pressed a key in time
if object collision(56,51) = 1
if canpress = 1
gosub lose
endif
if presses = 0
if canpress = 0
inc round
presses = 2
objonline = 0
gosub player2
endif
endif
time = 30
endif
if object collision(56,52) = 1
if canpress = 1
gosub lose
endif
if presses = 0
if canpress = 0
inc round
presses = 2
objonline = 0
gosub player2
endif
endif
time = 20
endif
if object collision(56,53) = 1
if canpress = 1
gosub lose
endif
if presses = 0
if canpress = 0
inc round
presses = 2
objonline = 0
gosub player2
endif
endif
time = 20
endif
if object collision(56,54) = 1
time = 20
endif
`sets timer after moving wall hits wall
if time > 0 then time = time - 1
if time = 0 then canpress = 1
if canpress = 1 then time = -1
`moves the moving wall
position object 56, movex#,-.4,-1
movex# = movex# - .03
if movex# < -7
if canpress = 0
inc round
presses = 2
objonline = 0
gosub player2
endif
movex# = 8
endif
if presses = 0
canpress = 0
endif
sync
loop
`if you lose
lose:
cls
do
text 100,100,"Haha you lost cuz you suck so what now!"
if returnkey() = 1
end
endif
sync
loop
player2:
player = 2
`makes the player 2 array
dim keypresses2(10)
presses = presses + round
cls
`reset variables
objx = 9
objy = 0
movex# = 8
canpress = 1
arrowslot2 = 1
for a = 1 to 10
delete object a
next a
return
do
cls
`print variables
print objonline
print time
text 0,0,str$(keypresses2(1))
text 0,10,str$(keypresses2(2))
text 0,20,str$(keypresses2(3))
text 0,30,str$(keypresses2(4))
text 0,40,str$(keypresses2(5))
text 0,50,str$(keypresses2(6))
text 0,60,str$(keypresses2(7))
text 0,70,str$(keypresses2(8))
text 0,80,str$(keypresses2(9))
text 0,90,str$(keypresses2(10))
text 0,110,str$(presses)
text 0,120,str$(player)
`checks whether or not array is full
if movex# < -7
if arrowslot2 = 10
end
endif
endif
`make up arrow
if upkey() = 1
if canpress = 1
arrow = arrow + 1
load object "arrow.x",arrow
objx = objx - 3
canpress = 0
objonline = objonline + 1
texture object arrow,1
set object emissive arrow,rgb(255,0,0)
keypresses2(arrowslot2) = 1
inc arrowslot
inc objects
dec presses
endif
endif
`make left arrow
if leftkey() = 1
if canpress = 1
arrow = arrow + 1
load object "arrow.x",arrow
zrotate object arrow, 270
objx = objx - 3
canpress = 0
objonline = objonline + 1
texture object arrow,2
set object emissive arrow,rgb(0,0,255)
keypresses2(arrowslot2) = 2
inc arrowslot
inc objects
dec presses
endif
endif
`make right arrow
if rightkey() = 1
if canpress = 1
arrow = arrow + 1
load object "arrow.x",arrow
zrotate object arrow, 90
objx = objx - 3
canpress = 0
objonline = objonline + 1
texture object arrow,3
set object emissive arrow,rgb(0,255,0)
keypresses2(arrowslot2) = 3
inc arrowslot
inc objects
dec presses
endif
endif
`positions arrows
if object exist(arrow)
scale object arrow, 20,20,20
position object arrow,objx,objy,0
endif
`checks whether or not to go to the next line
if objonline > 5
objy = -1
objx = 6
objonline = 0
endif
`checks for wall collision so you can add press arrows again and checks if you've pressed a key in time
if object collision(56,51) = 1
if canpress = 1
gosub lose
endif
time = 30
endif
if object collision(56,52) = 1
if canpress = 1
gosub lose
endif
time = 20
endif
if object collision(56,53) = 1
if canpress = 1
gosub lose
endif
time = 20
endif
if object collision(56,54) = 1
time = 20
endif
`sets timer after moving wall hits wall
if time > 0 then time = time - 1
if time = 0 then canpress = 1
if canpress = 1 then time = -1
`moves the moving wall
position object 56, movex#,-.4,-1
movex# = movex# - .03
if movex# < -7
movex# = 8
canpress = 1
endif
if presses = 0
gosub player1
endif
sync
loop
return
<a href="http://j3msoft.com">My gaming company's website.</a>