I'm trying to create a game where you shoot targets with a paintball gun. Each time you pull the trigger, the desired effect is an image, selected at random, pasted at the current mousex and mousey, that will remain there.
I tried setting up an array so that on every click, the current mousex and mousey are saved. At the same time, I tried pasting a randomly selected sprite.
Set Display Mode 1024,768,32
Sync On
Hide Mouse
Randomize Timer()
MX = mousex()
MY = mousey()
PSC = 200 `start number of splat sprites.
Global lcommand as Integer
Global command as Integer
Global MTrigger as String
load image "tex\spl\splat1b.tga",101,1
load image "tex\spl\splat1r.tga",102,1
load image "tex\spl\splat1g.tga",103,1
load image "tex\spl\splat1o.tga",104,1
load image "tex\spl\splat2b.tga",105,1
load image "tex\spl\splat2r.tga",106,1
load image "tex\spl\splat2g.tga",107,1
load image "tex\spl\splat2o.tga",108,1
load image "tex\spl\splat3b.tga",109,1
load image "tex\spl\splat3r.tga",110,1
load image "tex\spl\splat3g.tga",111,1
load image "tex\spl\splat3o.tga",112,1
do
gosub Setup
do
gosub Fire
gosub ScrRf
loop
`gosub Level
`gosub EndGame
loop
Setup:
`dim PSx()
`dim PSy()
sprite 101,0,0,101
sprite 102,0,0,102
sprite 103,0,0,103
sprite 104,0,0,104
sprite 105,0,0,105
sprite 106,0,0,106
sprite 107,0,0,107
sprite 108,0,0,108
sprite 109,0,0,109
sprite 110,0,0,110
sprite 111,0,0,111
sprite 112,0,0,112
return
ScrRf:
sync
return
Fire:
OnLMC()
if MTrigger="SHOOT"
inc PSC,1
` PSx(PSC) = MX
` PSy(PSC) = MY
PSI = 101+rnd(11)
REM This is what I want to work
` sprite PSC,PSx(PSC),PSy(PSC),PSI
REM This is as close as I can come
sprite PSC,MX,MY,PSI
endif
return
Function OnLMC()
lcommand=command
command=MouseClick()
` not held Down
if command=0 and lcommand=0 then MTrigger="NUL"
` held Down
if command=1 and lcommand=0 then MTrigger="SHOOT"
` just Been Pressed
if command=1 and lcommand=1 then MTrigger="NUL"
` just been Lifted
if command=0 and lcommand=1 then MTrigger="NUL"
Endfunction
Problem is, I don't think arrays work inside an "if" command, rendering my attempt at saving the mousex/mousey of old clicks futile.
If anyone has played Goldeneye on N64 with the paintball cheat, I'm trying to do exactly the same thing, but with 2D instead of 3D.