heres two pieces of code from something i was working a while back...
This ones the beginning of a paintball course Strategy/Building game (barely got anywhere lol), but its very bugged, such as the wall still "moves" in its coordinates after youve placed it, the wall goes offscreen, and other things, that i never took the time to fix, then i abandoned the project. Here it is, press "W" to make a wall, dont move the mouse before you do or the wall will end up offscreen(it moves kinda fast), click to place, right click to unplace, and you can only make one wall
:
Rem Project: Paintball Tycoon
Rem Created: 3/28/2004 5:49:21 PM
Rem ***** Main Source File *****
sync on : sync rate 1000
autocam off
hide mouse
rem load variables
gosub load_variables
rem load textures
gosub load_textures
rem load world
gosub load_world
rem setup sounds
gosub setup_sounds
rem setup music
gosub setup_music
rem setup camera
gosub setup_camera
rem setup objects
gosub setup_objects
rem NPS's
gosub setup_nps
rem setup character
gosub setup_character
rem setup buildings
gosub setup_buildings
do
gosub control_player
gosub control_mouse
gosub control_objects
sync
gosub control_enemies
gosub control_effects
gosub control_sounds
sync
loop
rem load variables
load_variables:
`mousex#=mousex()
`mousey#=mousey()
`mousez#=mousez()
return
rem load textures
load_textures:
`load the textures to be used in the game
set dir "media"
load image "textures/grass/grass01.jpg",1
load image "textures/metal/iron01.bmp",2
return
rem load world
load_world:
`makes the ground for the game
make matrix 1,1000,1000,1,1
prepare matrix texture 1,1,1,1
return
rem setup sounds
setup_sounds:
return
rem setup music
setup_music:
return
rem setup camera
setup_camera:
`setup starting position of the camera
z#=-50
x#=0
`points camera down at an angle
xrotate camera 40
return
rem setup objects
setup_objects:
`setup variable to move the object
ox=ox+mousemovex()
oz=oz-mousemovey()
make object cube 1,1
scale object 1,300,300,50
texture object 1,2
position object 1,500,5,500
hide object 1
clone object 2,1
scale object 2,300,300,50
texture object 2,2
position object 2,500,5,500
hide object 2
clone object 3,1
scale object 3,300,300,50
texture object 3,2
position object 3,500,5,500
hide object 3
clone object 4,1
scale object 4,300,300,50
texture object 4,2
position object 4,500,5,500
hide object 4
clone object 5,1
scale object 5,300,300,50
texture object 5,2
position object 5,500,5,500
hide object 5
clone object 7,1
scale object 7,300,300,50
texture object 7,2
position object 7,500,5,500
hide object 7
clone object 6,1
scale object 6,300,300,50
texture object 6,2
position object 6,500,5,500
hide object 6
return
rem NPS's
setup_nps:
return
rem setup character
setup_character:
return
rem setup buildings
setup_buildings:
return
rem main loop
wall001x#=object position x(1)
wall001z#=object position z(1)
wall001#=0
cameraup#=0
obj#=2
position mouse wall001x#,wall001y#
control_player:
if keystate(17)=1
show object 1`1`
exsists001#=1
endif
if mouseclick()=0 and exsists001#=1
ox=ox+mousemovex()
oz=oz-mousemovey()
endif
`if wall001x#>x#+10
`position object 1,x#,1.5,oz
`endif
if exsists001#=1 and wall001#<.5
position object 1,ox,1.5,oz
endif
position camera x#,40,z#
if downkey()=1
z#=z#-1
endif
if upkey()=1
z#=z#+1
endif
if rightkey()=1
x#=x#+1
endif
if leftkey()=1
x#=x#-1
endif
return
control_mouse:
if wall001#>wall001#+1
wall001#=1
endif
if mouseclick()=1 and exsists001#=1
wall001#=wall001#+1
show mouse
endif
if mouseclick()=2 and exsists001#=1
wall001#=0
hide mouse
endif
return
control_objects:
return
control_enemies:
return
control_effects:
return
control_sounds:
return
You'll have to replace those 2 textures with ur own, or just not use them. Heres something that i asked for help on is creating more than one object, if u still need that(never implemented it into my game):
`turn manual syncing on and sync rate to auto or 0
sync on : sync rate 0
`turn manual camera positioning on and hide mouse
autocam off : hide mouse
`make matrix just for visual referrence
make matrix 1, 500, 500, 50, 50
`position camera over the matrix looking down at the center
position camera 250,500,250
point camera 250,0,250
`make a variable to hold the next objects number
next_object = 1
do
`if the c key is pressed make a cube
if keystate(46) = 1
`safety variable created to make sure it only creates one cube
`each time the key is pressed
if ckp = 0
`turn variable on so it can't make another cube until the
`c key is released
ckp = 1
`make a cube
gosub make_cube
endif
else
`reset the safety variable when the c key is released
ckp = 0
endif
`if the s key is pressed create 1 sphere
`has the same safety as the cube code
if keystate(31) = 1
if skp = 0
skp = 1
gosub make_sphere
endif
else
skp = 0
endif
`if an object has been created move it around with arrow keys
if next_object > 1
if upkey() =1
`point object forward and move
yrotate object next_object-1, 0
move object next_object-1, 1
endif
if downkey() =1
`point object backwards and move
yrotate object next_object-1, 180
move object next_object-1, 1
endif
if leftkey() =1
`point object left and move
yrotate object next_object-1, 270
move object next_object-1, 1
endif
if rightkey() =1
`point object right and move
yrotate object next_object-1, 90
move object next_object-1, 1
endif
endif
`draw changes to the screen
sync
loop
end
make_cube:
`make a cube and increment the next_object variable
make object cube next_object, 20
inc next_object, 1
return
make_sphere:
`make a sphere and increment the next_object variable
make object sphere next_object, 20
inc next_object, 1
return
Video games…they can take you places unreachable, impossible, unfeasible. They put you in the book...they put you in the movie...they put you in a world, a world that before could only be imagined.