Been posting a lot recently, as the due date is looming and I'm looking for those extra marks
This first code snippet I've come up with is to cycle through the different vehicle types. At present it works well, but I'm trying to have the actual model of the vehicle load and rotate as you cycle them.
I'm sure my code will make some of you more competent programmers weep, so I'll apologise now.
on = RGB(197,22,27)
off = RGB(189,189,192)
COLOR BACKDROP RGB(255,255,255)
DO REM -------- Player 1 Vehicle Selection -----------------------------
REM -------- Next Vehicle --------
IF (((MOUSEX() >= 320) AND (MOUSEX() <= 330)) AND ((MOUSEY() >= 810) AND (MOUSEY() <=830))) THEN INK on,0 :SET TEXT SIZE 25:TEXT 320,810,">"
IF (((MOUSEX() <= 319) OR (MOUSEX() >= 331)) OR ((MOUSEY() <= 809) OR (MOUSEY() >= 831))) THEN INK off,0 :SET TEXT SIZE 22:TEXT 320,810,">"
IF ((((MOUSEX() >= 320) AND (MOUSEX() <= 330)) AND ((MOUSEY() >= 810) AND (MOUSEY() <=830) AND (MOUSECLICK()=1))))
PLAY SOUND 5
suspend()
player1Car = player1Car+1
ENDIF
SET TEXT SIZE 22
REM -------- Previous Vehicle --------
IF (((MOUSEX() >= 150) AND (MOUSEX() <= 160)) AND ((MOUSEY() >= 810) AND (MOUSEY() <=830))) THEN INK on,0 :SET TEXT SIZE 25:TEXT 150,810,"<"
IF (((MOUSEX() <= 149) OR (MOUSEX() >= 161)) OR ((MOUSEY() <= 809) OR (MOUSEY() >= 831))) THEN INK off,0 :SET TEXT SIZE 22:TEXT 150,810,"<"
IF ((((MOUSEX() >= 150) AND (MOUSEX() <= 160)) AND ((MOUSEY() >= 810) AND (MOUSEY() <=830) AND (MOUSECLICK()=1))))
PLAY SOUND 5
suspend()
player1Car = player1Car-1
ENDIF
SET TEXT SIZE 22
REM -------- Selected Vehicle --------
IF player1Car > 6 THEN player1Car = 1
IF player1Car < 1 THEN player1Car = 6
INK RGB(30,42,201),0
IF player1Car=1
CENTER TEXT SCREEN WIDTH()/2-400,840, "Police Car"
IF OBJECT EXIST(6)=1 THEN DELETE OBJECT 6
LOAD OBJECT "Media\Models\X Models\Vehicles\Police Car\H-Police Car-Move.X",6
LOAD IMAGE "Media\Models\X Models\Vehicles\Police Car\policeCa.DDS",60
TEXTURE OBJECT 6,60
ENDIF
IF player1Car=2 THEN CENTER TEXT SCREEN WIDTH()/2-400,840, "Stock Car"
IF player1Car=3 THEN CENTER TEXT SCREEN WIDTH()/2-400,840, "Taxi"
IF player1Car=4 THEN CENTER TEXT SCREEN WIDTH()/2-400,840, "4x4"
IF player1Car=5 THEN CENTER TEXT SCREEN WIDTH()/2-400,840, "Small Car"
IF player1Car=6 THEN CENTER TEXT SCREEN WIDTH()/2-400,840, "Beach Buggy"
rem Rotate object
IF OBJECT EXIST(6)=1
IF player1Car<>6
YROTATE OBJECT 6,OBJECT ANGLE Y(6)+0.25
ENDIF
ENDIF
SYNC
LOOP
I found this demo included within the version of DB Pro I'm using, and though there pretty much the same I can't figure why mines not working.
Apologies, it's a the whole which works.
Rem Project: SpecialEffects
rem Use desktop resolution, vsync on
sync on : sync rate 30
desktopwidth=desktop width()
desktopheight=desktop height()
set display mode desktopwidth,desktopheight,32,1
`color backdrop rgb(192,192,192)
rem Toggle starter
togglemode=-1
rem Main loop
do
rem Switch mode
if spacekey()=1 `or togglemode=-1
`
if togglemode<>-1
while spacekey()=1 : sync : endwhile
endif
`
rem Next mode
inc togglemode
if togglemode=5 then togglemode=0
`endif
rem One Command Version : Loads default model and textures
if togglemode=0
if object exist(1)=1 then delete object 1
LOAD OBJECT "Media\Models\X Models\Vehicles\Police Car\L-Police Car-Move.X",1
LOAD IMAGE "Media\Models\X Models\Vehicles\Police Car\policeCa.DDS",60
TEXTURE OBJECT 1,60
`effect$="cartoon.fx"
`set effect on 1,effect$,1
endif
`
rem Two Command Version : Apply to existing object using default textures
if togglemode=1
effect$="rainbow.fx"
if object exist(1)=1 then delete object 1
load object "default.x",1
set effect on 1,effect$,1
endif
`
rem Six Command Version : Apply to existing object using own textures
if togglemode=2
effect$="bump.fx"
if object exist(1)=1 then delete object 1
make object sphere 1,1,20,20
load image "base.tga",1
load image "bump.dds",2
texture object 1,0,1
texture object 1,1,2
set effect on 1,effect$,0
endif
`
rem Additional Effect
if togglemode=3
effect$="metal.fx"
if object exist(1)=1 then delete object 1
set effect on 1,effect$,1
endif
`
rem Additional Effect
if togglemode=4
effect$="water.fx"
if object exist(1)=1 then delete object 1
set effect on 1,effect$,1
scale object 1,250,100,250
position object 1,-1000,250,-2000
endif
`
endif
rem Rotate object
if object exist(1)=1
if togglemode<>4
yrotate object 1,object angle y(1)+0.25
endif
endif
rem Set light for the effects using mouse
set point light 0,(mousex()-320),(240-mousey()),-200
rem Prompt user
center text screen width()/2,20,"SPECIAL EFFECT FROM FX FILE - HIT SPACE FOR NEXT ONE"
center text screen width()/2,40,"CURRENT EFFECT "+str$(1+togglemode)+" : "+upper$(effect$)
if togglemode=0 then center text screen width()/2,screen height()-40,"DESC : FX EFFECT IN ONE COMMAND (DEFAULT MODEL AND TEXTURES USED)"
if togglemode=1 then center text screen width()/2,screen height()-40,"DESC : FX EFFECT ON EXISTING OBJECT (DEFAULT TEXTURES USED)"
if togglemode=2 then center text screen width()/2,screen height()-40,"DESC : FX EFFECT ON EXISTING OBJECT AND EXISTING TEXTURES"
rem Update screen
sync
rem End loop
loop
Is there anything that stands out such as the use of CLS, sync or backdrop that would stop the model displaying on screen?