Hi, a while back I started a post entitled "placing objects with mouse", it was for a turn based stradegy game, Aura, whent out of his way to help. But that thread has long but pasted, and I am left with one more troubeling delemma, bullets. you see, I want to be able to select the unit, and be able to shoot with the space key. sense alot of this code was made by Aura, I have a hard time figuring out exactly what is going on, thus its hard to implement thing (great code though). My original design was that the player would have to hold down the space bar to shoot farther, the longer you hold down the farther it goes. so that the players have to learn to get the shot just right to hit the enemy. I also want the the players turn to be over right after they take the shot. I know this is alot to ask for, but I really want to complete a project. Here is the code....
`..............................._________....................................................................................
`................______________/_________\_______________.............................................................
`............../ \...........................................................
`............./ \____________________________________________..............
`............/ ]___________________________________________]
`------------------------------------------------------------------------------.....................................
`[ US ARMY \...................................
`[ \..................................
`[ ` ___________________________________ \.................................
`[___________________/ \_________________________\................................
`..\ /....................................
`...\ /.....................................
`....\ /......................................
`.....\_____________________________________________________________________/........................................
numturns = 0
do
inc numturns
if numturns = 1
goSub placestuff
else
do
rem print timer
set cursor 0,0
print "Player ",player(0)," Has ",timeleft(0)," Time Left "
rem the new object selection code
if object screen x(2000)=<mousex()
position object 2000,object position x(2000)+4,object position y(2000),object position z(2000)
endif
if object screen x(2000)=>mousex()
position object 2000,object position x(2000)-4,object position y(2000),object position z(2000)
endif
if object screen y(2000)=<mousey()
position object 2000,object position x(2000),object position y(2000),object position z(2000)-4
endif
if object screen y(2000)=>mousey()
position object 2000,object position x(2000),object position y(2000),object position z(2000)+4
endif
if player(0)=2
rem the select bit (replace with distance equation) Player 2
if mouseclick()=1
for t=6 to 10
if object position x(2000)=<object position x(t)+10
if object position x(2000)=>object position x(t)-10
if object position y(2000)=<object position y(t)+10
if object position y(2000)=>object position y(t)-10
if object position z(2000)=<object position z(t)+10
if object position z(2000)=>object position z(t)-10
if selection(0)=0
selection(0)=1
selected(0)=t
endif
endif
endif
endif
endif
endif
endif
next t
endif
if mouseclick()=1
for t=32 to 52
if object position x(2000)=<object position x(t)+10
if object position x(2000)=>object position x(t)-10
if object position y(2000)=<object position y(t)+10
if object position y(2000)=>object position y(t)-10
if object position z(2000)=<object position z(t)+10
if object position z(2000)=>object position z(t)-10
if selection(0)=0
selection(0)=1
selected(0)=t
endif
endif
endif
endif
endif
endif
endif
next t
endif
if upkey()=1 then position object selected(0),object position x(selected(0)),object position y(selected(0)),object position z(selected(0))+0.5
if downkey()=1 then position object selected(0),object position x(selected(0)),object position y(selected(0)),object position z(selected(0))-0.5
if leftkey()=1 then position object selected(0),object position x(selected(0))-0.5,object position y(selected(0)),object position z(selected(0))
if rightkey()=1 then position object selected(0),object position x(selected(0))+0.5,object position y(selected(0)),object position z(selected(0))
selection(0)=0
endif
if player(0)=1
rem the select bit (replace with distance equation) Player 1
for t=1 to 5
if mouseclick()=1
if object position x(2000)=<object position x(t)+10
if object position x(2000)=>object position x(t)-10
if object position y(2000)=<object position y(t)+10
if object position y(2000)=>object position y(t)-10
if object position z(2000)=<object position z(t)+10
if object position z(2000)=>object position z(t)-10
if selection(0)=0
selection(0)=1
selected(0)=t
endif
endif
endif
endif
endif
endif
endif
endif
next t
for t=11 to 31
if mouseclick()=1
if object position x(2000)=<object position x(t)+10
if object position x(2000)=>object position x(t)-10
if object position y(2000)=<object position y(t)+10
if object position y(2000)=>object position y(t)-10
if object position z(2000)=<object position z(t)+10
if object position z(2000)=>object position z(t)-10
if selection(0)=0
selection(0)=1
selected(0)=t
endif
endif
endif
endif
endif
endif
endif
endif
next t
if upkey()=1 then position object selected(0),object position x(selected(0)),object position y(selected(0)),object position z(selected(0))+0.5
if downkey()=1 then position object selected(0),object position x(selected(0)),object position y(selected(0)),object position z(selected(0))-0.5
if leftkey()=1 then position object selected(0),object position x(selected(0))-0.5,object position y(selected(0)),object position z(selected(0))
if rightkey()=1 then position object selected(0),object position x(selected(0))+0.5,object position y(selected(0)),object position z(selected(0))
selection(0)=0
endif
timeleft(0)=timeleft(0)-1
if timeleft(0)=<0
if player(0)=1
player(0)=2
color object 2000,RGB(150,0,0)
else
player(0)=1
color object 2000,RGB(0,0,150)
endif
timeleft(0)=1200
endif
sync
loop
endif
sync
loop
placestuff:
rem Init display
randomize timer()
set display mode 800,600,16
sync on
sync rate 60
autocam off
Set camera range 1,10000
position mouse screen width()/2, screen height()/2
backdrop on
color backdrop rgb(0,0,0)
dim selection(0)
dim player(0)
dim timeleft(0)
dim selected(0)
selection(0)=0
player(0)=1
timeleft(0)=1200
selected(0)=1
`mouse object
make object sphere 2000,6
position object 2000 ,-100,0,-100
set object collision to polygons 2000
color object 2000,RGB(0,0,150)
ghost object on 2000
`make tanks for player 1
for t=1 to 5
Load object "tank1.3ds",t
load bitmap "tank uv.bmp",1
get image 1,0,0,512,512
scale object t,500,500,500
rotate object t,250,0,0
fix object pivot t
texture object t,1
delete bitmap 1
position object t,-100+rnd(100),0,-300+rnd(100)
set object collision to polygons t
next t
`make tanks for player 2
for t=6 to 10
load object "tank2.3ds",t
load bitmap "tankplayer2.BMP",2
get image 2,0,0,512,512
texture object t,2
scale object t,500,500,500
rotate object t,250,0,180
delete bitmap 2
position object t,-100+rnd(100),0,100+rnd(100)
set object collision to polygons t
next t
`rem make infantry
for s=11 to 31
make object sphere s,5
position object s,-100+rnd(100),0,-400+rnd(100)
set object collision to polygons s
color object s,RGB(0,0,150)
next s
`rem make infantry for player 2
for s=32 to 52
make object sphere s,5
position object s,100+rnd(100),0,100+rnd(100)
set object collision to polygons s
color object s,RGB(150,0,0)
next s
`REM Bunkers
for p= 53 to 58
make object box p, 20,20,20
position object p,-300+rnd(100),0,-300+rnd(100)
set object collision to polygons p
color object p,RGB(0,0,150)
next p
`bunkers for player 2
for p= 59 to 64
make object box p, 20,20,20
position object p,-300+rnd(100),0,100+rnd(100)
color object p,RGB(150,0,0)
next p
position camera -100,550,-100
xrotate camera 90
do
`rem camera control
rem print timer
set cursor 0,0
print "Player ",player(0)," Has ",timeleft(0)," Time Left "
rem the new object selection code
if object screen x(2000)=<mousex()
position object 2000,object position x(2000)+4,object position y(2000),object position z(2000)
endif
if object screen x(2000)=>mousex()
position object 2000,object position x(2000)-4,object position y(2000),object position z(2000)
endif
if object screen y(2000)=<mousey()
position object 2000,object position x(2000),object position y(2000),object position z(2000)-4
endif
if object screen y(2000)=>mousey()
position object 2000,object position x(2000),object position y(2000),object position z(2000)+4
endif
if player(0)=2
rem the select bit (replace with distance equation) Player 2
if mouseclick()=1
for t=6 to 10
if object position x(2000)=<object position x(t)+10
if object position x(2000)=>object position x(t)-10
if object position y(2000)=<object position y(t)+10
if object position y(2000)=>object position y(t)-10
if object position z(2000)=<object position z(t)+10
if object position z(2000)=>object position z(t)-10
if selection(0)=0
position object t,object position x(2000),object position y(2000),object position z(2000)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next t
endif
selection(0)=0
endif
if player(0)=1
rem the select bit (replace with distance equation) Player 1
if mouseclick()=1
for t=1 to 5
if object position x(2000)=<object position x(t)+10
if object position x(2000)=>object position x(t)-10
if object position y(2000)=<object position y(t)+10
if object position y(2000)=>object position y(t)-10
if object position z(2000)=<object position z(t)+10
if object position z(2000)=>object position z(t)-10
if selection(0)=0
position object t,object position x(2000),object position y(2000),object position z(2000)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next t
endif
selection(0)=0
endif
`infantry selection
if player(0)=2
rem the select bit (replace with distance equation) Player 2
if mouseclick()=1
for s=32 to 52
if object position x(2000)=<object position x(s)+10
if object position x(2000)=>object position x(s)-10
if object position y(2000)=<object position y(s)+10
if object position y(2000)=>object position y(s)-10
if object position z(2000)=<object position z(s)+10
if object position z(2000)=>object position z(s)-10
if selection(0)=0
position object s,object position x(2000),object position y(2000),object position z(2000)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next s
endif
selection(0)=0
endif
if player(0)=1
rem the select bit (replace with distance equation) Player 1
if mouseclick()=1
for s=11 to 31
if object position x(2000)=<object position x(s)+10
if object position x(2000)=>object position x(s)-10
if object position y(2000)=<object position y(s)+10
if object position y(2000)=>object position y(s)-10
if object position z(2000)=<object position z(s)+10
if object position z(2000)=>object position z(s)-10
if selection(0)=0
position object s,object position x(2000),object position y(2000),object position z(2000)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next s
endif
selection(0)=0
endif
`bunker placement
if player(0)=2
rem the select bit (replace with distance equation) Player 2
if mouseclick()=1
for p=59 to 64
if object position x(2000)=<object position x(p)+10
if object position x(2000)=>object position x(p)-10
if object position y(2000)=<object position y(p)+10
if object position y(2000)=>object position y(p)-10
if object position z(2000)=<object position z(p)+10
if object position z(2000)=>object position z(p)-10
if selection(0)=0
position object p,object position x(2000),object position y(2000),object position z(2000)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next p
endif
selection(0)=0
endif
if player(0)=1
rem the select bit (replace with distance equation) Player 1
if mouseclick()=1
for p=53 to 58
if object position x(2000)=<object position x(p)+10
if object position x(2000)=>object position x(p)-10
if object position y(2000)=<object position y(p)+10
if object position y(2000)=>object position y(p)-10
if object position z(2000)=<object position z(p)+10
if object position z(2000)=>object position z(p)-10
if selection(0)=0
position object p,object position x(2000),object position y(2000),object position z(2000)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next p
endif
selection(0)=0
endif
timeleft(0)=timeleft(0)-1
if timeleft(0)=<0
if player(0)=1
player(0)=2
color object 2000,RGB(150,0,0)
else
player(0)=1
numturns = 1
repeat
set text size 50
CENTER text 400,300,"LET THE BATTLE BEGIN"
set cursor 10,10
print "press return to start"
SYNC
until returnkey()=1
return
color object 2000,RGB(0,0,150)
endif
timeleft(0)=1200
endif
sync
loop
there are some models and textures in there, just replace the "load object" command with a "make object cube", and delete the texture bit.
Thanks.
P4 3.2Ghz/Alienware area 51/radeon 9800 pro 256mb/sound blaster audigy 2/5.1 surround sound speakers.