Posted: 19th Feb 2004 13:22
[DBP] Just trying some things out before beginning on a car game.
Already had my object bumping boxes, now it is smoking and... jumping!!! Jumping 'car'



+ Code Snippet
REM -- Just for 'fun', bumping objects
REM -- BY Dennuz666.com

set display mode 800,600,32

autocam off
sync off
backdrop on
color backdrop 0

set ambient light 100

REM -- SETUP MATRIX
make matrix 1,500,500,20,20

REM SETUP PLAYER
make object cube 1,20
set object wireframe 1,1
REM -- TILT Object (not used in this code)
make object cone  6, 5
hide limb 6,0

glue object to limb 1,6,0

REM -- CREATE SMOKE OBJECTS
dim object_smoke_on(500)
dim object_smoke_ghost(500)
dim object_smoke_scale(500)
smoke_timer = 100
smoke_timer_delay = 0

REM -- MAX NR OF OBJECTS = UNKNOWN
maxobjects = 200

for a = 100 to 100+maxobjects
   make object plain a,10,10
   hide object a
   object_smoke_on(a) = 0
   ghost object on a
next a

spd# = 0
jump = 0
jumph# = 10
jump_bounce# = 1

REM -- MAIN LOOP
DO
   REM -- SET CAMERA
   position camera 0,100,0
   point camera object position x(6),object position y(6),object position z(6)

   REM -- CONTROL PLAYER WITH ARROW KEYS
   if upkey() = 1
      spd# = curvevalue(5,spd#,50)
   endif

   if upkey() = 0
      if spd# > 0.2
         spd# = curvevalue(0,spd#,50)
      endif
   endif

   x#=newxvalue(x#,a#,spd#)
    z#=newzvalue(z#,a#,spd#)

    if leftkey()=1 then a#=wrapvalue(a#-5.0)
    if rightkey()=1 then a#=wrapvalue(a#+5.0)

    REM -- PLAYER JUMP
    if spacekey() = 1 and jump <> 1 and y# < 2
      jump = 1
      jump_on# = jumph#
    endif

    if jump = 1
      inc y#,jump_on#
      dec jump_on#,0.25
      if jump_on# <= 0
         jump = 2
      endif
    endif

    if jump > 1
      dec y#,jump_on#
      inc jump_on#,0.25
      if y# < 0
         y# = 0
         jump = 1
         inc jump_bounce#,1
         jump_on# = jumph#/jump_bounce#
         if jump_bounce# = 4
            jump_bounce# = 1
            jump = 0
         endif
      endif
    endif

   REM -- UPDATE PLAYER OBJECT
   yrotate object 6,a#
   position object 6,x#,y#,z#

   inc smoke_timer,1
   If smoke_timer > (100+maxobjects)
      smoke_timer = 100
   endif


   If object_smoke_on(smoke_timer) = 0
      rem if upkey() = 1 and spd# < 3
      rem ALWAYS SMOKE
         show object smoke_timer
         position object smoke_timer,((x#-5)+rnd(10)),y#,z#+10
         yrotate object smoke_timer,a#
         object_smoke_on(smoke_timer) = 1
         object_smoke_ghost(smoke_timer) = 80
         object_smoke_scale(smoke_timer) = 100
      rem endif
   endif

   for smoke = 100 to 100+maxobjects

   If object_smoke_on(smoke) = 1
      set object to camera orientation smoke
      inc object_smoke_scale(smoke),5
      scale object smoke,object_smoke_scale(smoke),object_smoke_scale(smoke),object_smoke_scale(smoke)
      fade object smoke,object_smoke_ghost(smoke)
      dec object_smoke_ghost(smoke),1
      position object smoke,object position x(smoke),object position y(smoke)+1,object position z(smoke)
      if object_smoke_ghost(smoke) = 0
       object_smoke_ghost(smoke)= 80
       object_smoke_on(smoke) = 0
       hide object smoke
      endif
   endif

   next smoke

   set cursor 1,1
   print screen fps()

   sync rate 50

LOOP


Weird thing i couldn't get rid of, is at certain camera angles the smoke cant be seen (shadow side?). Tried to 'ambient light' them but didn't work out. Anyone?
Posted: 19th Feb 2004 14:08
Texture the planes.
Posted: 19th Feb 2004 15:33
It works! TNX!!!

+ Code Snippet
REM -- Just for 'fun', bumping objects
REM -- BY Dennuz666.com

set display mode 800,600,32

autocam off
sync off
backdrop on
color backdrop 0

REM -- SETUP MATRIX
make matrix 1,500,500,20,20

REM SETUP PLAYER
make object cube 1,20
set object wireframe 1,1
REM -- TILT Object (not used in this code)
make object cone  6, 5
hide limb 6,0

glue object to limb 1,6,0

REM -- CREATE SMOKE OBJECTS
load image "smoke.jpg",100

dim object_smoke_on(500)
dim object_smoke_ghost(500)
dim object_smoke_scale(500)
smoke_timer = 100
smoke_timer_delay = 0

REM -- MAX NR OF OBJECTS = UNKNOWN
maxobjects = 200

for a = 100 to 100+maxobjects
   make object plain a,10,10
   texture object a,100
   hide object a
   object_smoke_on(a) = 0
   set object transparency a,1
   ghost object on a
next a

spd# = 0
jump = 0
jumph# = 10
jump_bounce# = 1

REM -- MAIN LOOP
DO
   REM -- SET CAMERA
   position camera 0,100,0
   point camera object position x(6),object position y(6),object position z(6)

   REM -- CONTROL PLAYER WITH ARROW KEYS
   if upkey() = 1
      spd# = curvevalue(5,spd#,50)
   endif

   if upkey() = 0
      if spd# > 0.2
         spd# = curvevalue(0,spd#,50)
      endif
   endif

   x#=newxvalue(x#,a#,spd#)
    z#=newzvalue(z#,a#,spd#)

    if leftkey()=1 then a#=wrapvalue(a#-5.0)
    if rightkey()=1 then a#=wrapvalue(a#+5.0)

    REM -- PLAYER JUMP
    if spacekey() = 1 and jump <> 1 and y# < 2
      jump = 1
      jump_on# = jumph#
    endif

    if jump = 1
      inc y#,jump_on#
      dec jump_on#,0.25
      if jump_on# <= 0
         jump = 2
      endif
    endif

    if jump > 1
      dec y#,jump_on#
      inc jump_on#,0.25
      if y# < 0
         y# = 0
         jump = 1
         inc jump_bounce#,1
         jump_on# = jumph#/jump_bounce#
         if jump_bounce# = 4
            jump_bounce# = 1
            jump = 0
         endif
      endif
    endif

   REM -- UPDATE PLAYER OBJECT
   yrotate object 6,a#
   position object 6,x#,y#,z#

   inc smoke_timer,1
   If smoke_timer > (100+maxobjects)
      smoke_timer = 100
   endif


   If object_smoke_on(smoke_timer) = 0
      rem if upkey() = 1 and spd# < 3
      rem ALWAYS SMOKE
         show object smoke_timer
         position object smoke_timer,((x#-5)+rnd(10)),y#,z#+10
         yrotate object smoke_timer,a#
         object_smoke_on(smoke_timer) = 1
         object_smoke_ghost(smoke_timer) = 100
         object_smoke_scale(smoke_timer) = 100
      rem endif
   endif

   for smoke = 100 to 100+maxobjects

   If object_smoke_on(smoke) = 1
      set object to camera orientation smoke
      inc object_smoke_scale(smoke),5
      scale object smoke,object_smoke_scale(smoke),object_smoke_scale(smoke),object_smoke_scale(smoke)
      fade object smoke,object_smoke_ghost(smoke)
      dec object_smoke_ghost(smoke),1
      position object smoke,object position x(smoke),object position y(smoke)+1,object position z(smoke)
      if object_smoke_ghost(smoke) = 0
       object_smoke_ghost(smoke)= 100
       object_smoke_on(smoke) = 0
       hide object smoke
      endif
   endif

   next smoke

   set cursor 1,1
   print screen fps()

   sync rate 50

LOOP


Media:
Posted: 21st Feb 2004 13:01
Looks beautiful but a FPS of 3 makes it unplayable. And that's on a scene with one matrix and a box! Not to mention without collision detection either!