TGC Codebase Backup



MyFirstScene by Anonymous Coder

18th Sep 2005 8:08
Summary

This sample might eventually be of some help for other newbyes like myself. It shows 3 objects spinning (with some FX) over a terrain. Please enjoy it.



Description

Hi, I discovered yesterday (sep, 17th) DarkBasic and in a couple of (night) hours this first scenario came up.
It is simple, surely perfettible, ingenuos, and so on...but it was funny to create, and particularly frustrating !
I'm not sure to continue with Dark Basic, since it is quite distant from what I was expecting. It lacks most of what I need to write graphical programs (not Games !), like controls and events.
I did not find any documentation on the site thus it would difficult for me to proceed (and to decide to buy it), but again...it was funny.
This sample might eventually be of some help for other newbyes like myself.
Please enjoy it.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM Project: Test1
REM Created: 17/09/2005 12.12.22
REM by Giacomo
REM ***** Main Source File *****
REM

REM --------- VARIABLES
obj1 = 10
sw1 = 1
sw2 = 2
sw3 = 3
flag1 = 0
flag2 = 0
flag3 = 0

rem backdrop off

SET IMAGE COLORKEY 192 , 192 , 192
load image "Ball1.bmp",1
load image "StainGlass.bmp",2
load image "InThePool.jpg",3
load image "Switch_off.bmp",4
load image "Switch_on.bmp",5
load image "green.bmp", 6
load image "yellow.bmp", 7
load image "red.bmp", 8
load image "drop.jpg", 9

text 10,10,"Card: " + CURRENT GRAPHICS CARD$()


REM --------- LIGHT
make light 1
color light 1 , 128 , 220 , 255
position light 1,-120,50,-200
point light 1,0,30,0
rem show light 1

MAKE TERRAIN 1 , "GreyLevels.bmp"
POSITION TERRAIN 1 , -200, -50, -50
TEXTURE TERRAIN 1 , 9

REM --------- CONTROLS
MAKE OBJECT PLAIN sw1 , 30 , 30
MAKE OBJECT PLAIN sw2 , 30 , 30
MAKE OBJECT PLAIN sw3 , 30 , 30
POSITION OBJECT 1 , 220.0 , 160.0 , 0.0
POSITION OBJECT 2 , 220.0 , 115.0 , 0.0
POSITION OBJECT 3 , 220.0 , 70.0 , 0.0
TEXTURE OBJECT 1 , 6
TEXTURE OBJECT 2 , 7
TEXTURE OBJECT 3 , 8

rem --------- Create the visual Cube
make object cube obj1, 100
POSITION OBJECT obj1 ,0,40,-120
rem color object obj1 ,rgb(128,128,128)
SET OBJECT specular obj1 , rgb(255,0,0)
SET OBJECT EMISSIVE obj1 , rgb(255,0,0)
SET OBJECT SPECULAR POWER obj1 , 127
texture object obj1 ,2
INSTANCE OBJECT obj1+1 , obj1
INSTANCE OBJECT obj1+2 , obj1
POSITION OBJECT obj1+1 , -40, -40, -200
POSITION OBJECT obj1+2 , 300, 240, 300


rem --------- CAMERA
position camera 0,0,-300
CONTROL CAMERA USING ARROWKEYS 0, 100, 100
point camera 0,0,0


REM ----------- MAIN LOOP
perc=100
cnt=0
slope = 1
ink rgb(255,255,255) , rgb (0,100,30)
rem SET TEXT OPAQUE

do
   ZROTATE OBJECT obj1 ,OBJECT ANGLE Z(obj1) + 0.2
   YROTATE OBJECT obj1 ,OBJECT ANGLE Y(obj1) + 0.1
   ZROTATE OBJECT obj1+1 ,OBJECT ANGLE Z(obj1+1) + 0.15
   XROTATE OBJECT obj1+1 ,OBJECT ANGLE X(obj1+1) + 0.3
   XROTATE OBJECT obj1+2 ,OBJECT ANGLE X(obj1+2) + 0.25
   YROTATE OBJECT obj1+2 ,OBJECT ANGLE Y(obj1+2) + 0.15

   ob = 0
   msClick = 0
   text 745,60,"Fading"
   text 745,135,"DualTex"
   text 745,210,"Ghost"

   msClick = mouseclick()

   if msClick > 0
      X = MOUSEX()
      Y = MOUSEY()
      ob = PICK OBJECT( X , Y , sw1 , sw3)
      text 10,25,"Button: " + str$(ob)

      select ob
      CASE 1
         flag1 = not flag1
      ENDCASE
      CASE 2
         flag2 = not flag2
         if flag2=1 then SET DETAIL MAPPING ON obj1 , 1 else texture object obj1 ,2
      ENDCASE
      CASE 3
         flag3 = not flag3
         if flag3=1 then ghost object on obj1 else ghost object off obj1
      ENDCASE
      endselect

   endif

   if flag1 = 1
      if cnt=10
         SET ALPHA MAPPING ON obj1, perc
         perc = perc + slope
         if slope = 1 and perc > 99 then slope = -1
         if slope = -1 and perc < 2 then slope = 1
         cnt=0
      endif
      cnt=cnt+1
   endif

loop