RemStart
*/
Title : FPS Camera[Demo]
Version : 1.0.0.3 (0001.0002)
Created: : 24/12/2002 21:19:38
Developer: Raven Vegeta [RGD]
Publisher: FreeSource™
Additional Credits :
Avril Lavinge (gotta listen to tunes whilst developing)
Skittles (Mmmm need i say more)
-- Description ----
<< Please See Readme file for more information >>
/*
RemEnd
`-- Include ----
`-- Setup Environment ----
sync on : sync rate 0
autocam off
`-- Program Cache ----
#constant TRUE 1 : #constant FALSE 0 : #constant VOID 0
`-- Structures ----
`// camera vector
type tau
x as float :`// x space point
y as float :`// y space point
z as float :`// z space point
endtype
type camera
ang as tau :`// angle
pos as tau :`// position
old as tau :`// old angle
endtype
cam as camera :`// declare camera
`// player control (all pretty self explainitory)
type player
up
down
left
right
jump
crouch
endtype
key as player :`// declare player keys
`// time variable
type time
old as float
duration as float
current as float
endtype
time as time :`// declare time
`== Ask for Keybinds ====
`key.up = keybind("walk forward") :`// simple keybind function
`-- Setup Game Environment ----
`// create fog
if fog available() = TRUE
fog on
fog color rgb(128,128,128)
fog distance 1200
endif
`// create a grey sky
backdrop on
color backdrop rgb(128,128,128)
`// create camera (not needed really but good to use incase of zoom and such)
make camera 1
set current camera 1
`-- Media ----
Rem make matrix
make matrix 1,1000,1000,20,20
`// matrix texture
maketexture(1,256)
prepare matrix texture 1,1,1,1
fill matrix 1,0,1
`== PreProgram ===
`// camera base variable
cam.pos.x = .0
cam.pos.y = 175.0
cam.pos.z = .0
position camera 1,cam.pos.x,cam.pos.y,cam.pos.z
`// start pipeline timer
time.old = timer()
`== Main Program ====
do
gosub _pipeline :`// get loop sync time (in ms)
`// store old camera
cam.old.y = Camera Angle Y()
cam.old.x = Camera Angle X()
if time.duration > .05
`<< time based operations go here >>
cam.ang.y = WrapValue(cam.ang.y+MousemoveX()*0.3)
cam.ang.x = WrapValue(cam.ang.x+MousemoveY()*0.3)
gosub _controls :`// grab controls pressed
endif
`// update camera
rotate camera 1,curveangle(cam.ang.x,cam.old.x,24),curveangle(cam.ang.y,cam.old.y,24),curveangle(cam.ang.z,cam.old.z,24)
position camera 1,cam.pos.x,cam.pos.y,cam.pos.z
sync
loop
`== Subrountines ====
`// pipeline timer (milliseconds)
_pipeline:
time.current = timer()
time.duration = ( time.current - time.old )
time.old = time.current
return
`// keyboard controls
_controls:
if keystate(key.up) = TRUE
cam.pos.x = newxvalue(cam.pos.x,cam.ang.y,5.0)
cam.pos.z = newzvalue(cam.pos.z,cam.ang.y,5.0)
endif
if keystate(key.down) = TRUE
cam.pos.z = newzvalue(cam.pos.z,cam.ang.y,-5.0)
cam.pos.z = newzvalue(cam.pos.z,cam.ang.y,-5.0)
endif
if keystate(key.left) = TRUE
cam.pos.x = newxvalue(cam.pos.x,wrapvalue(cam.ang.y-90.0),2.5)
cam.pos.z = newzvalue(cam.pos.z,wrapvalue(cam.ang.y-90.0),2.5)
endif
if keystate(key.right) = TRUE
cam.pos.z = newzvalue(cam.pos.z,wrapvalue(cam.ang.y+90.0),2.5)
cam.pos.z = newzvalue(cam.pos.z,wrapvalue(cam.ang.y+90.0),2.5)
endif
return
`====================
`== Functions ====
`// keybinder
function keybind(effect as string)
bool as boolean
state as byte
while bool = FALSE
input "please enter "+effect+" key",state
if state > 0 then bool = TRUE
endwhile
endfunction state
function maketexture(image as word,size as dword)
memblock = image
if memblock exist(memblock) = TRUE
memblock = memblock + 1
else
make memblock memblock,12+(2*(size^2))
write memblock dword memblock,0,size
write memblock dword memblock,4,size
write memblock dword memblock,8,16
position = 12
for index = 0 to 256^2
write memblock word memblock,position,rgb(rnd(255),rnd(255),rnd(255))
next index
make bitmap from memblock image,memblock
delete memblock memblock
endif
endfunction
`=================
RemStart
*/
-- Disclaimer ----
FMT, FMTau, FreeSource are trademarks of FMTau Software, L.L.C.
-- Copyrights ----
Raven Graphical Developments is part of FMTau Labs, L.L.C.
Copyright 2002© Raven Vegeta, Raven Graphical Developments. All rights reserved.
/*
RemEnd
for some reason the vector no matter what i renamed it, dbpro was having non of it - but you can always replace that all with either a real vector variable or with different letters or something, i'm too tired to really figure it out
but the principals are sound, most of this is the DB normal tutorial code if my memory serves me - just tweaked to personal preferance
Anata aru kowagaru no watashi! 