I was searching and found a open source fps NOX on this forum writted in DB Pro. The thread is here:
http://forum.thegamecreators.com/?m=forum_view&t=111818&b=8
The thread has kind of died out. I realized it had a lot of great potential, I tryed to port this to C++ and Dark GDK.
Yes there are problems and I'm not done with converting but its open source, so whoever wants to help can go ahead. The media and the DB Pro source is found on the link above. Check the DBPro source because some of my conversions may be incorrect
The code WILL NOT COMPILE, I am aware and anybody who would like to help, please go ahead. But this is open-source so post on this thread when you have a contribution.
Code is released under GNU General Public License. I will update the code from time to time,so I will edit this post, and I suggest you check the edit post time.
//Open-source fps port of now. Original in DBPro
//Please contribute.
#include "DarkGDK.h"
#include "SC_Collision.h"
int freeSound();
int freeimage();
int freeobject();
int id;
//Main function in DarkGDK
void DarkGDK ( void )
{
dbSyncOn( );
dbSyncRate ( 0 );
dbHideMouse ( );
dbColorBackdrop( dbRGB(0,0,0));
dbBackdropOff( );
dbAutoCamOff( );
dbSetCameraFOV ( 80 );
dbSetCameraRange ( 1, 2000 );
dbSetAmbientLight ( 25 );
dbColorAmbientLight(dbRGB(200,200,200));
int Scr_width; Scr_width = dbScreenWidth();
int Scr_height; Scr_height = dbScreenHeight();
int I_flash;
int I_head;
int o_glass;
//Sound
dbLoadMusic ( "Loop.mp3", 1 ); dbLoopMusic ( 1 );
int s_footstep; s_footstep = freeSound(); dbLoadSound ( "footstep.wav", s_footstep) ; dbLoopSound ( s_footstep ); dbPauseSound ( s_footstep );
int s_attack; s_attack = freeSound(); dbLoadSound ( "hurt.wav",s_attack );
int s_bullstart; s_bullstart = freeSound(); dbLoadSound ( "diesel_start.wav", s_bullstart );
int s_bullrun; s_bullrun = freeSound(); dbLoadSound ( "diesel_run.wav", s_bullrun ); dbLoopSound ( s_bullrun ); dbPauseSound ( s_bullrun );
int s_bullsTop ; s_bullsTop = freeSound(); dbLoadSound ( "diesel_sTop.wav",s_bullsTop );
int s_door_open ; s_door_open = freeSound() ; dbLoadSound ( "door_open.wav", s_door_open );
int s_door_close ; s_door_close = freeSound() ; dbLoadSound ( "door_close.wav", s_door_close );
int s_reload; s_reload = freeSound() ; dbLoadSound ( "reload.wav", s_reload );
int s_skelly_die; s_skelly_die = freeSound() ; dbLoadSound ("skelly_die.wav", s_skelly_die );
int s_key1; s_key1 = freeSound(); dbLoadSound ( "key_2.wav",s_key1 );
int s_key2; s_key2 = freeSound(); dbLoadSound ( "key_1.wav",s_key2 );
//guns
int o_gun; o_gun = freeobject();
int s_gun; s_gun = freeSound();
int gun_active; gun_active = o_gun;
int n_gun; n_gun = 4;
int reload;
int gun_click;
dbLoadObject ("crowbar.x",o_gun); dbLoadSound ("crowbar.wav",s_gun);
dbLoadObject ("canon.x",o_gun+1); dbLoadSound ("canon.wav",s_gun+1);
dbLoadObject ("shotgun.x",o_gun+2); dbLoadSound ("shotgun.wav",s_gun+2);
dbLoadObject ("minigun.x",o_gun+3); dbLoadSound ("canon.wav",s_gun+3);
dbLoadObject ("uzi.x",o_gun+4); dbLoadSound ("canon.wav",s_gun+4);
for ( id = o_gun; id <= o_gun+n_gun; id++ )
{
dbScaleObject ( id, 10, 10, 10 );
dbDisableObjectZDepth ( id );
dbHideObject ( id );
}
dbShowObject ( o_gun );
extern int ammo[n_gun]; ammo[0]=100; ammo[1]=0; ammo[2]=0; ammo[3]=0; ammo[4]=0;
extern int e_ammo[n_gun][2];
//decals
int o_decal; o_decal = freeobject();
int n_decal; n_decal=80;
int t_decal; t_decal=o_decal;
for (id = o_decal; id <= o_decal+n_decal; id++)
{
dbLoadObject ( "decal.x", id );
dbSetObjectTransparency ( id,2 );
dbDisableObjectZWrite ( id );
}
//flashLight
null = dbMakeVector4(1);
null = dbMakeMatrix4(2);
null = dbMakeMatrix4(3);
null = dbMakeMatrix4(4);
null = dbMakeMatrix4(5);
//distance calculations
null = dbMakeVector3(6);
//constants && ints
int o_level;
int o_player;
int o_monster; int n_monster;
int o_bullet; int n_bullet; n_bullet = 10;
#define r_player 18
#define r_monster 18
int health; health=100;
int flashLight; flashLight=1000;
int o_door; int n_door;
int o_health; int n_health;
int o_ammo; int n_ammo;
int o_story; int n_story;
int o_key; int n_key;
int o_elevator ; int n_elevator;
int e_door[50];
int e_story[50];
int e_key[50];
//refraction
dbMakeCamera ( 1 );
dbSetCameraRange ( 1, 15, 200 );
dbSetCameraFOV ( 1, 100 );
dbSetCameraAspect (1, 1.35f);
dbBackdropOff ( 1 );
dbSetCameraToImage ( 1, 1, 64, 64 );
int I_glas ; I_glass = freeimage()
dbLoadImage ( "glass.bmp", I_glass );
dbLoadEffect ( "refraction.fx", 3, 0 );
dbSetEffectConstantFloat (3, "U" , 1);
//Setup voids
Makelevel();
Makeplayer();
Makemonster();
Makebullet();
int t_bullet[n_bullet];
int door[n_door];
int m_health[n_monster];
for (id = 0; id <= n_monster; id++)
{
m_health[id]=100;
}
int t_monster(n_monster);
int b_monster(n_monster);
int bullet(n_bullet);
int bullet_active;
int bullet_click;
bullet_active = o_bullet;
int vy;
int ground; ground = 1;
int jumptimer; jumptimer = 0;
int tick;
int tick_Movement;
int hud_img; hud_img = freeimage()
int hud_spr; hud_spr = freeSprite()
dbCreateAnimatedSprite ( hud_spr, "hud.png", 1, 5, hud_img );
i_icons=freeimage(); dbLoadImage ( "hud_icons.png", i_icons, 1 );
s_icons=freeSprite(); dbSprite ( s_icons, 12, Scr_height-104, i_icons );
i_cursor=freeimage(); dbLoadImage ( "hud_cursor.png", i_cursor, 1 );
s_cursor=freeSprite(); dbSprite ( s_cursor,Scr_width/2-8,Scr_height/2-8,i_cursor );
i_hurt=freeimage(); dbLoadImage ( "hud_hurt.png", i_hurt, 1 );
int s_hurt; s_hurt=freeSprite(); dbSprite ( s_hurt, 0, 0, i_hurt ); dbSetSpriteAlpha ( s_hurt, 0 );
i_fade=freeimage(); dbLoadImage ( "hud_fade.png", i_fade, 1 );
int s_fade; s_fade=freeSprite() ; dbSprite ( s_fade, 0, 0, i_fade ) ; dbSetSpriteAlpha ( s_fade, 0 );
int hurt; hurt=0;
int ticker_monster;
ticker_monster = o_monster;
int dist[n_monster];
int awake[n_monster];
int tempdist[n_monster];
int seeplayer[n_monster];
for (id = 0; id <= n_monster; id++)
{
dist[id]=500;
awake[id]=0;
tempdist[id]=0;
seeplayer[id]=0;
}
mode = 1;
int o_car; o_car = freeobject();
dbMakeObjectSphere ( o_car, 40 );
dbHideObject ( o_car );
SC_SetupObject ( o_car, 0, 1 );
SC_AllowObjectScaling ( o_car );
SC_UpdateObject ( o_car );
dbLoadObject ( "bull.x", o_car+1 );
dbPositionObject ( o_car+1, 0, -20, 0 );
dbGlueObjectToLimb ( o_car+1, o_car, 0 );
dbLoadObject ( "left.x", o_car+2 );
dbGlueObjectToLimb ( o_car+2, o_car+1, 0 );
dbLoadObject ( "Right.x", o_car+3 );
dbGlueObjectToLimb ( o_car+3, o_car+1, 0 );
dbPositionObject ( o_car, 470, -350, 1140 );
SC_UpdateObject ( o_car );
//font
int font_y;
int font_img; font_img = freeimage();
int font_spr; font_spr = freeSprite();
dbCreateAnimatedSprite ( font_spr, "font.png", 10, 5, font_img );
int numbers_img; numbers_img = freeimage();
int numbers_spr; numbers_spr = freeSprite();
dbCreateAnimatedSprite ( numbers_spr, "numbers.png", 11, 1, numbers_img );
//water
dbLoadEffect ( "water.fx", 2, 0 );
i_water=freeimage() ; dbLoadImage ( "water.png", i_water );
i_normwater=freeimage() ; dbLoadImage ( "water_normal.bmp", i_normwater );
o_water=freeobject(); dbLoadObject ( "water.x", o_water);
dbScaleObject ( o_water, 50, 50, 50 );
dbSetObjectTransparency ( o_water, 1 );
dbTextureObject ( o_water, 0, i_water );
dbTextureObject ( o_water, 1, i_normwater );
dbSetObjectEffect ( o_water, 2 );
//cull
for (id=1; id <= 5000; id++)
{
if (dbObjectExist(id) == 1) { dbSetObjectCull ( id, 1 ); }
}
tm_init()
tm_factor=0.1
do
tm_update();
handleitems();
dbPositionMouse (dbScreenWidth()/2,dbScreenHeight()/2);
dbScrollObjectTexture ( o_water, 0.0001*tm_result, 0 );
if (health < 0);
{
dead();
}
hurt -= 2;
if (hurt < 0)
{
hurt = 0;
}
dbSetSpriteAlpha ( s_hurt, hurt );
font_y = 16;
display_text("fps; " + dbStr(dbScreenFps()));
display_text("polygons; "+ dbStr(dbStatistic(1)));
display_numbers(str$(flashLight/10),48,Scr_height-104);
if (gun_active = o_gun)
{
display_numbers("/",48,Scr_height-72);
}
else
{
display_numbers(str$(ammo(gun_active-o_gun)),48,Scr_height-72);
}
display_numbers(str$(health),48,Scr_height-40)
if (dbKeyState(18) == 1 && e_click == 0)
{
dbSetVector3 ( 6, dbObjectPositionX(o_player)- dbObjectPositionX(o_car),dbObjectPositionY(o_player)-dbObjectPositionY(o_car),dbObjectPositionZ(o_player)-dbObjectPositionZ(o_car));
idist = dbLengthVector3(6);
if (dist<50 || mode == -1)
{
mode = mode*-1;
switch = 1;
}
e_click = 1;
}
else
{
if (dbKeyState(18) == 0) { e_click=0; }
}
//fps mode
if (mode == 1)
{
if switch=1
dbTextureObject ( o_level, 2, I_flash );
dbShowSprite ( s_cursor );
dbStopSound ( s_bullrun );
dbPlaySound ( s_bullsTop );
dbShowObject ( gun_active );
SC_SetObjectCollisionOn ( o_player );
dbPositionObject ( o_player, dbObjectPositionX(o_car), dbObjectPositionY(o_car)+20, dbObjectPositionZ(o_car) );
dbYRotateObject ( o_player, dbObjectAngleY(o_car+1) );
for id=O_bullet To O_bullet+N_bullet
SC_SetObjectCollisionOn ( id );
next id
switch=0
endif
dbSetCurrentCamera ( 0 );
int pick = dbPickObject(Scr_width/2,Scr_height/2,o_level,o_key+n_key);
if (dbGetPickDistance()<100 )
{
if (pick >= o_door && pick=< o_door+n_door)
{
if (e_door(pick - o_door) == 0)
{
dbSetSpriteFrame ( hud_spr, 1); dbPasteSprite ( hud_spr, dbObjectScreenX(pick)-32, dbObjectScreenY(pick)-16);
}
else
{
dbSetSpriteFrame ( hud_spr, 2 ); dbPasteSprite ( hud_spr, dbObjectScreenX(pick)-32, dbObjectScreenY(pick)-16 );
}
if (dbMouseClick() == 2)
{
if e_door(pick-o_door)=0
{
if door(pick-o_door)<0 { door(pick - o_door)=250; }
}
}
}
if (pick >= o_health && pick=<o_health+n_health)
{
dbSetSpriteFrame ( hud_spr, 4); dbPasteSprite ( hud_spr, dbObjectScreenX(pick)-32, dbObjectScreenY(pick)-16);
if (dbMouseClick() == 2)
{
health += 25;
dbHideObject ( pick );
}
}
if pick>=o_ammo && pick=<o_ammo+n_ammo
dbSetSpriteFrame ( hud_spr, 3); dbPasteSprite ( hud_spr, dbObjectScreenX(pick)-32,dbObjectScreenY(pick)-16);
if Mouseclick()=2
ammo(e_ammo(pick-o_ammo,2))=ammo(e_ammo(pick-o_ammo,2))+e_ammo(pick-o_ammo,1)
dbHideObject ( pick );
dbPlaySound ( s_reload );
dbHideObject ( gun_active );
gun_active = e_ammo[pick-o_ammo][2]+1
if (gun_active > o_gun+n_gun) { gun_active = o_gun+n_gun;}
if (gun_active < o_gun) { gun_active=o_gun; }
dbShowObject ( gun_active );
endif
endif
if ( pick >= o_story && pick =< o_story+n_story)
{
dbSetSpriteFrame ( hud_spr, 5 ); dbPasteSprite ( hud_spr, dbObjectScreenX(pick)-32,dbObjectScreenY(pick)-16
if (dbMouseClick() == 2)
{
dbSetSpriteAlpha ( s_fade, 255 );
dbHideSprite ( s_cursor );
dbHideSprite ( s_icons );
do
font_y = 112
if e_story(pick-o_story)=0
display_text("instructions;")
display_text("wasd - Movement")
display_text("space - jump")
display_text("f - flashLight")
display_text("e - start vehicle")
display_text("rmd - fire")
display_text("mmb - change weapon")
display_text("lmb - use/pick Up")
endif
if e_story(pick-o_story)=1
display_text("sam -")
display_text("sorry i didnt wake you.")
display_text("ive gone Down To Loading deck a.")
display_text("josh said he dug Up something unusual.")
display_text("come Down when your ready.")
display_text("- matt")
endif
if e_story(pick-o_story)=2
display_text("sam -")
display_text("god what are these things.")
display_text("josh is badly hurt.")
display_text("i am taking him Up To accident && emergency.")
display_text("come as soon as you can.")
display_text("you had better take your canon.")
display_text("there could be more of them.")
display_text("- matt")
endif
if e_story(pick-o_story)=3
display_text("sam -")
display_text("im sorry, so sorry.")
display_text("i couldnt save josh.")
display_text("they were waiting for us.")
display_text("me, craig && daniel are leading them Up To")
display_text("Loading deck b.")
display_text("i dont know how long we can hold out...")
display_text("get help.")
display_text("- matt")
endif
if e_story(pick-o_story)=4
display_text("sam -")
display_text("you have To get out of here.")
display_text("get word To the surface.")
display_text("we need a full Scale evacuation.")
display_text("see if you can cLimb Up To that old duct.")
display_text("good luck son.")
display_text("ill see you on Top.")
display_text("- your loving father, matt")
endif
if e_story(pick-o_story)=5
display_text("sam -")
display_text("the bridge is broken.")
display_text("jump Down && take the disused elevator shaft.")
display_text("- matt")
endif
if e_story(pick-o_story)=6
display_text("sam -")
display_text("my proud of you boy.")
display_text("youve done well To Make it this far.")
display_text("ive gone ahead on foot.")
display_text("take the bulldozer, these mines are dangerous.")
display_text("- matt")
endif
if e_story(pick - o_story)=7
display_text("sam -")
display_text("you made it.")
display_text("this elevator shaft will take you To the surface.")
display_text("if your Up for it, we are planning a reSCue mission.")
display_text("see you soon.")
display_text("- dad")
inc font_y,16
display_text("sorry folks, this is the end of the demo.")
display_text("i would like To thank sparky,evolved,edgen,mayang")
display_text("lost in thought,flamboyant fish, && everyone else")
display_text("who helped on the forums. cheers guys.")
endif
if e_story(pick-o_story)=7 && Mouseclick()=1 then end
if (dbMouseClick() == 1) then exit
dbPositionMouse (dbScreenWidth()/2,dbScreenHeight()/2);
null=dbMouseMoveX()
null=dbMouseMoveY()
dbFastSync( );
Loop
dbShowSprite ( s_icons );
dbShowSprite ( s_cursor );
dbSetSpriteAlpha ( s_fade,0 );
endif
endif
if pick>=o_key && pick=<o_key+n_key
if Scroll = 0 then Scroll Object Texture pick,0.5,0 ; Scroll = pick ; dbPlaySound s_key1
if Mouseclick()=2
for id=0 To n_door
if e_door(id)=e_key(pick-o_key) then e_door(id)=0 ; Scroll Object Texture pick,0,0.5 ; dbPlaySound s_key2
next id
endif
else
if ( Scroll > 0 ) { dbScrollObjectTexture ( Scroll, -0.5, 0 ); Scroll = 0;
endif
endif
for id=o_door To o_door+n_door
if door(id-o_door)=210 then SC_SetObjectcollisionOff id
if door(id-o_door)=90 then SC_SetObjectCollisionOn id
if door(id-o_door)=250 then dbPlaySound s_door_open ; play Object id
if door(id-o_door)=90 then dbPlaySound s_door_close
door(id-o_door)=door(id-o_door)-1
next id
for id=o_elevator To o_elevator+n_elevator
dbMoveObjectUp ( id, sin(tick)*2 );
SC_UpdateObject ( id );
next id
handlemonster()
handleplayer()
handlegun()
handlebullet()
//Camera
dbPositionCamera (dbObjectPositionX(o_player), dbObjectPositionY(o_player)+18,dbObjectPositionZ(o_player));
dbRotateCamera (dbObjectAngleX(o_player), dbObjectAngleY(o_player), dbObjectAngleZ(o_player) );
//lock gun
dbSetObjectToCameraOrientation ( gun_active );
dbPositionObject gun_active,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ()
dbMoveObject ( gun_active, 6 );
dbMoveObjectDown ( gun_active, 5+sin(tick_Movement)/2 );
dbMoveObjectRight ( gun_active,6+sin(tick_Movement)/4 );
if (l_on == 1) { flashLight -= 1; }
if (l_on == 0 && flashLight < 1000) { flashLight += 2; }
if (flashLight<0) { l_on = 0; }
//flashLight
if (dbKeyState(33)==1 && f_click ==0 && l_on == 0) { l_on=1; f_click=1; }
if (dbKeyState(33)==1 && f_click ==0 && l_on == 1) { l_on=0; f_click=1; }
if (l_on == 0) { f_brightness -= 0.1; }
if (l_on == 1) { f_brightness += 0.1; }
if (f_brightness>1) { f_brightness=1; }
if (f_brightness<0) { f_brightness=0; }
dbSetEffectConstantFloat (1, "bRightness", f_brightness );
if (dbKeyState(33) == 0)
{
f_click = 0;
}
if (f_brightness > 0);
{
dbSetVector4 ( 1, dbCameraPositionX(),dbCameraPositionY()-5,dbCameraPositionZ(),0
Set Effect constant vecTor 1,"LightPosition",1
x_Angle=curveAngle(dbCameraAngleX(),x_Angle,10)
y_Angle=curveAngle(dbCameraAngleY(),y_Angle,10)
dbRotateXMatrix4 ( 2, (x_Angle)/57.3 );
dbRotateYMatrix4 ( 3, (y_Angle)/57.3 );
dbRotateZMatrix4 ( 4, (z_Angle)/57.3 );
dbMultiplyMatrix4 ( 5, 2, 3 );
dbMultiplyMatrix4 ( 5, 5, 4 );
dbSetEffectConstantMatrix ( 1, "LightAngle", 5 );
}
//Color gun
col=point(400,300)
newr=dbCurveValue(dbRGBR(col),oldr,10)
newg=dbCurveValue(dbRGBG(col),oldg,10)
newb=dbCurveValue(dbRGBB(col),oldb,10)
dbSetObjectDiffuse ( gun_active, dbRGB(newr,newg,newb) );
oldr=newr;
oldg=newg;
oldb=newb;
//vehicle mode
else
if switch=1
dbTextureObject ( o_level, 2, I_head );
dbHideSprite ( s_cursor );
dbPlaySound ( s_bullstart );
dbPlaySound ( s_bullrun );
dbLoopSound ( s_bullrun );
dbHideObject ( gun_active );
SC_SetObjectCollisionOff ( o_player );
for id=O_bullet To O_bullet+N_bullet
SC_SetObjectCollisionOff id
next id
switch=0
endif
dbSetSoundSpeed ( s_bullrun, 35000+dbAbs(int(acc*2000)) );
oldx = dbObjectPositionX(o_car)
oldy = dbObjectPositionY(o_car)
oldz = dbObjectPositionZ(o_car)
if acc>0 then dec acc,0.08
if acc<0 then inc acc,0.08
if ( dbKeyState(17) == 1)
{
inc acc,0.1
if acc>4 then acc=4
dbScrollObjectTexture ( o_car+2,0,0.01*tm_result );
dbScrollObjectTexture ( o_car+3,0,0.01*tm_result );
}
if (dbKeyState(31) == 1)
{
acc -= 0.1;
if acc<-2 then acc=-2;
dbScrollObjectTexture ( o_car+2, 0, -0.005*tm_result );
dbScrollObjectTexture ( o_car+3, 0, -0.005*tm_result );
}
if dbKeyState(32)=1 then rot_car=dbWrapValue(rot_car+1*tm_result); dbScrollObjectTexture ( o_car+2, 0, 0.005*tm_result);
if dbKeyState(30)=1 then rot_car=dbWrapValue(rot_car-1*tm_result); dbScrollObjectTexture ( o_car+3, 0, 0.005*tm_result);
v_x=dbNewXValue(dbObjectPositionX(o_car),rot_car,acc*tm_result)
v_z=dbNewZValue(dbObjectPositionZ(o_car),rot_car,acc*tm_result)
dbPositionObject ( o_car,v_x, dbObjectPositionY(o_car)-(2*tm_result),v_z);
dbYRotateObject ( o_car+1, rot_car );
x = dbObjectPositionX(o_car);
y = dbObjectPositionY(o_car);
z = dbObjectPositionZ(o_car);
collide = SC_Sphereslide(0,oldx,oldy,oldz,x,y,z,40,o_car)
if ( collide >= o_monster && collide <= o_monster+n_monster)
{
m_health(collide-o_monster)=m_health(collide-o_monster)-25
if m_health(collide-o_monster)<=0
{
SC_RemoveObject ( collide );
dbPlaySound ( s_skelly_die );
}
}
for id=o_monster To o_monster+n_monster
SC_SetObjectcollisionOff id
next id
collide = SC_Sphereslide(0,oldx,oldy,oldz,x,y,z,40,o_car)
if ( collide > 0)
{
dbPositionObject ( o_car, SC_GetCollisionSlideX(),SC_getcollisionslidey(),SC_getcollisionslidez()
}
for ( id = o_monster; id <= o_monster+n_monster; id++ )
{
SC_SetObjectCollisionOn ( id );
}
x = dbObjectPositionX(o_car)
y = dbObjectPositionY(o_car)
z = dbObjectPositionZ(o_car)
collide = SC_rayCast(0,x,y,z,x,y-50,z,o_car)
if (collide>0)
{
nx=SC_GetCollisionNormalX();
ny=SC_GetCollisionNormalY();
nz=SC_GetCollisionNormalZ();
nxang=dbAtanFull(nz,ny);
nyang=0;
nzang=dbAtanFull(nx,ny);
}
dbRotateObject ( o_car, dbCurveAngle(nxang,dbObjectAngleX(o_car),20/tm_result),nyang,dbCurveAngle(-nzang,dbObjectAngleZ(o_car),20/tm_result));
oldx = CameraPositionX();
oldy = CameraPositionY();
oldz = CameraPositionZ();
x=dbCurveValue(dbNewXValue(dbObjectPositionX(o_car),rot_car,-100),oldx,50/tm_result);
y=dbObjectPositionY(o_car)+50;
z=dbCurveValue(dbdbNewZValue(dbObjectPositionZ(o_car),rot_car,-100),oldz,50/tm_result);
dbPositionCamera (x,y,z);
collide = SC_SphereSlide(0,oldx,oldy,oldz,x,y,z,4,o_car);
if (collide>0)
{
dbPositionCamera (SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ());
}
dbPointCamera (dbObjectPositionX(o_car), dbObjectPositionY(o_car), dbObjectPositionZ(o_car));
SC_UpdateObject ( o_car );
dbPositionObject ( o_player, dbObjectPositionX(o_car), dbObjectPositionY(o_car), dbObjectPositionZ(o_car));
handlemonster();
dbSetEffectConstantFloat ( 1, "bRightness", 1 );
dbSetVector4 (1, dbObjectPositionX(o_car), dbObjectPositionY(o_car),dbObjectPositionZ(o_car),0);
dbSetEffectConstantVector ( 1, "LightPosition", 1 );
x_Angle = dbCurveAngle(dbObjectAngleX(o_car+1),x_Angle,10/tm_result)
y_Angle = dbCurveAngle(dbObjectAngleY(o_car+1),y_Angle,10/tm_result)
dbRotateXMatrix4 ( 2, (x_Angle)/57.3 );
dbRotateYMatrix4 ( 3, (y_Angle)/57.3 );
dbRotateZMatrix4 ( 4, (z_Angle)/57.3 );
dbMultiplyMatrix4 ( 5, 2, 3 );
dbMultiplyMatrix4 ( 5, 5, 4 );
dbSetEffectConstantMatrix ( 1, "LightAngle", 5 );
}
dbPositionCamera 1,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ()
dbRotateCamera 1,dbCameraAngleX(),dbCameraAngleY(),Camera Angle z()
dbHideObject ( o_glass );
dbSyncMask ( 0xF0000002 );
dbFastSync( );
dbShowObject ( o_glass );
dbSyncMask ( 0x00000001 );
dbFastSync( );
// update the screen
dbSync ( );
}
return;
}
void Makelevel()
{
I_flash = freeimage();dbLoadImage "flashLight.dds",I_flash,2
I_head = freeimage();dbLoadImage "headLight.dds",I_head,2
dbLoadEffect ("flashLight.fx", 1, 0 );
o_level = freeobject() ; dbLoadObject ( "level.dbo",o_level ); SC_SetupcomplexObject o_level,1,4 ; SC_AllowObjectSCaling o_level ; Scale Object o_level,50,50,50 ; SC_UpdateObject o_level
o_detail = freeobject() ; dbLoadObject ( "detail.x",o_detail ); Scale Object o_detail,50,50,50
o_glass = freeobject() ; dbLoadObject ( "glass.x",o_glass ); SC_SetupcomplexObject o_glass,1,4 ; SC_AllowObjectSCaling o_glass ; Scale Object o_glass,50,50,50 ; SC_UpdateObject o_glass
dbTextureObject ( o_glass, 0, 1 );
dbTextureObject ( o_glass, 1, I_glass );
dbSetObjectEffect ( o_glass, 3 );
dbTextureObject ( o_level, 2, I_flash );
dbSetObjectEffect ( o_level, 1 );
dbPerformChecklistForObjectLimbs ( o_level );
list = dbChecklistQuantity();
o_door = freeobject()
n_door = -1
for id=1 To (list-1)
if lower$(keyvalue$(Limb name$(o_level,id),"classname",""))="door"
++n_door
dbLoadObject ( "door.x", o_door+n_door );
dbSetObjectSpeed ( o_door+n_door, 5 );
dbYRotateObject ( o_door+n_door, val(keyvalue$(Limb name$(o_level,id),"Angle","0")));
dbPositionObject o_door+n_door,Limb Position x(o_level,id),Limb Position y(o_level,id),Limb Position z(o_level,id);
SC_SetupObject ( o_door+n_door, 0, 2 );
SC_AllowObjectScaling ( o_door+n_door );
SC_UpdateObject ( o_door+n_door );
e_door(n_door)=val(keyvalue$(Limb name$(o_level,id),"id","0"))
endif
next id
o_health = freeobject();
n_health = -1;
for id=1 To (list-1)
if lower$(keyvalue$(Limb name$(o_level,id),"classname",""))="health"
inc n_health
dbLoadObject ( "health.x", o_health+n_health );
dbScaleObject ( o_health+n_health, 50, 50, 50 );
dbPositionObject ( o_health+n_health, dbLimbPositionX(o_level,id),dbLimbPositionY(o_level,id),dbLimbPositionZ(o_level,id) );
endif
next id
o_ammo = freeobject()
n_ammo = -1
for ( id = 1; id <= (list-1); id++)
{
if lower$(keyvalue$(Limb name$(o_level,id),"classname",""))="ammo"
inc n_ammo
e_ammo(n_ammo,1) = val(keyvalue$(Limb name$(o_level,id),"ammo","10"))
e_ammo(n_ammo,2) = val(keyvalue$(Limb name$(o_level,id),"gun","1"))
dbLoadObject ( "ammo.x", o_ammo+n_ammo );
dbScaleObject ( o_ammo+n_ammo, 50, 50, 50 );
dbPositionObject ( o_ammo+n_ammo, dbLimbPositionX(o_level,id),dbLimbPositionY(o_level,id),dbLimbPositionZ(o_level,id));
endif
}
o_story = freeobject();
n_story = -1;
for id=1 to (list-1)
if lower$(keyvalue$(Limb name$(o_level,id),"classname",""))="story"
inc n_story
e_story(n_story)=val(keyvalue$(Limb name$(o_level,id),"id","1"))
dbLoadObject ( "note.x", o_story+n_story );
dbPositionObject ( o_story+n_story, dbLimbPositionX(o_level,id),dbLimbPositionY(o_level,id),dbLimbPositionZ(o_level,id));
endif
next id
o_key = freeobject()
n_key = -1
for id=1 to (list-1)
if lower$(keyvalue$(Limb name$(o_level,id),"classname",""))="key"
inc n_key
e_key(n_key)=val(keyvalue$(Limb name$(o_level,id),"id","1"))
dbLoadObject ( "button.x", o_key+n_key );
dbYRotateObject ( o_key+n_key, val(keyvalue$(Limb name$(o_level,id),"Angle","0")) );
dbPositionObject ( o_key+n_key,dbLimbPositionX(o_level,id), dbLimbPositionY(o_level,id), dbLimbPositionZ(o_level,id) );
endif
next id
o_elevator = freeobject()
n_elevator = -1
for id=1 To (list-1)
if lower$(keyvalue$(Limb name$(o_level,id),"classname",""))="elevator"
inc n_elevator
dbLoadObject "lift.x",o_elevator+n_elevator
dbPositionObject o_elevator+n_elevator,Limb Position x(o_level,id),Limb Position y(o_level,id),Limb Position z(o_level,id)
SC_SetupObject o_elevator+n_elevator,0,2
SC_AllowObjectSCaling o_elevator+n_elevator
Scale Object o_elevator+n_elevator,50,50,50
SC_UpdateObject o_elevator+n_elevator
endif
next id
}
void Makeplayer()
{
o_player = freeobject();
dbMakeObjectSphere ( o_player, r_player*2, 4, 4 );
dbHideObject ( o_player );
SC_SetupObject ( o_player, 0, 1 );
SC_AllowObjectScaling ( o_player );
SC_UpdateObject ( o_player );
}
void Makemonster()
{
dbPerformChecklistForObjectLimbs ( o_level );
list = dbChecklistQuantity();
o_monster = freeobject();
n_monster = -1;
for id=1 To (list-1)
if lower$(left$(Limb name$(o_level,id),17))="classname=monster"
inc n_monster
dbLoadObject ( "skelly.x", o_monster+n_monster+1000 ); dbScaleObject ( o_monster+n_monster+1000, 50, 50, 50); dbMoveObjectUp ( o_monster+n_monster+1000, 2 );
dbLoopObject ( o_monster+n_monster+1000, 1, 20 );
dbSetObjectInterpolation ( o_monster+n_monster+1000, 50 );
dbMakeObjectSphere ( o_monster+n_monster, r_monster*2 );
dbHideObject ( o_monster+n_monster );
dbGlueObjectToLimb o_monster+n_monster+1000,o_monster+n_monster,0
Rotate Limb o_monster+n_monster,0,0,270,0
dbPositionObject o_monster+n_monster,Limb Position x(o_level,id),Limb Position y(o_level,id),Limb Position z(o_level,id)
SC_SetupObject o_monster+n_monster,2,1
SC_AllowObjectSCaling o_monster+n_monster
SC_UpdateObject o_monster+n_monster
endif
next id
endvoid
void Makebullet()
o_bullet = freeobject()
for id=o_bullet To o_bullet+n_bullet
dbLoadObject ( "canon ball.x", id );
dbHideObject ( id );
SC_SetupObject ( id, 3, 1 );
SC_AllowObjectScaling ( id );
SC_UpdateObject ( id );
next id
endvoid
void handlebullet()
SC_SetObjectcollisionOff o_player
for id=o_bullet To o_bullet+n_bullet
if t_bullet(id-o_bullet)>0
t_bullet(id-o_bullet)=t_bullet(id-o_bullet)-1*tm_result
oldx = dbObjectPositionX(id)
oldy = dbObjectPositionY(id)
oldz = dbObjectPositionZ(id)
dbMoveObject id,5*tm_result
x = dbObjectPositionX(id)
y = dbObjectPositionY(id)
z = dbObjectPositionZ(id)
collide = SC_rayCast(0,oldx,oldy,oldz,x,y,z,id)
if collide>0
if collide>=o_monster && collide<=o_monster+n_monster
m_health(collide-o_monster)=m_health(collide-o_monster)-25
if m_health(collide-o_monster)<=0
SC_reMoveObject collide
dbPlaySound s_skelly_die
endif
else
if collide=o_level or collide=o_glass
dbPositionObject t_decal,SC_getStaticCollisionx(),SC_getStaticCollisiony(),SC_getStaticCollisionz()
dbPointObject t_decal,dbObjectPositionX(t_decal)+SC_getcollisionNormalx(),dbObjectPositionY(t_decal)+SC_getcollisionNormaly(),dbObjectPositionZ(t_decal)+SC_getcollisionNormalz()
dbMoveObject t_decal,0.1
inc t_decal
if t_decal>o_decal+n_decal then t_decal=o_decal
endif
dbPositionObject id,SC_getStaticCollisionx(),SC_getStaticCollisiony(),SC_getStaticCollisionz()
dbPointObject id,dbObjectPositionX(id)+SC_getcollisionbouncex(),dbObjectPositionY(id)+SC_getcollisionbouncey(),dbObjectPositionZ(id)+SC_getcollisionbouncez()
endif
endif
SC_UpdateObject id
else
if dbObjectVisible(id)=1 then Hide Object id ; SC_SetObjectcollisionOff id
endif
next id
SC_SetObjectCollisionOn o_player
endvoid
void handlegun()
dec reload,0.5*tm_result
if Mouseclick()=4 && gun_click=0
Hide Object gun_active
for id=0 To n_gun
inc gun_active ; if gun_active>o_gun+n_gun then gun_active=o_gun
if ammo(gun_active-o_gun)<>0 then exit
next id
dbShowObject ( gun_active );
gun_click=1
else
if Mouseclick()=0 then gun_click=0
endif
if (dbMouseClick() == 1 && reload < 0)
{
//crowbar
if (gun_active - o_gun == 0)
{
dbSetObjectFrame ( gun_active, 1 ); dbPlayObject ( gun_active ) ; dbSetObjectSpeed ( gun_active, 10*tm_result );
dbHideObject ( bullet_active );
dbPositionObject ( bullet_active, dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ());
dbSetObjectToCameraOrientation ( bullet_active );
t_bullet(bullet_active-o_bullet)=8
bullet_active++;
if (bullet_active > o_bullet+n_bullet)
{
bullet_active = o_bullet;
}
dbPlaySound ( s_gun );
reload = 30;
SC_SetObjectCollisionOn ( bullet_active );
}
//canon
if ( gun_active - o_gun = 1 && ammo(1)>0 )
{
dbSetObjectFrame ( gun_active, 1 ); dbPlayObject ( gun_active ); dbSetObjectSpeed ( gun_active, 10*tm_result);
dbShowObject ( bullet_active );
dbScaleObject ( bullet_active, 100, 100, 100 );
dbPositionObject ( bullet_active, dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ() );
dbSetObjectToCameraOrientation ( bullet_active );
t_bullet(bullet_active-o_bullet)=40;
++bullet_active;
if bullet_active>o_bullet+n_bullet then bullet_active=o_bullet
ammo(1)=ammo(1)-1
dbPlaySound ( s_gun+1 );
reload=20;
SC_SetObjectCollisionOn ( bullet_active );
}
//shotgun
if gun_active-o_gun = 2 && ammo(2)>0
Set Object Frame gun_active,1 ; play Object gun_active ; Set Object Speed gun_active,10*tm_result
Show Object bullet_active
Scale Object bullet_active,50,50,50
dbPositionObject bullet_active,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ()
Set Object To Camera orientation bullet_active
dbMoveObject Right bullet_active,4
t_bullet(bullet_active-o_bullet)=80
inc bullet_active
if bullet_active>o_bullet+n_bullet then bullet_active=o_bullet
SC_SetObjectCollisionOn bullet_active
dbShowObject ( bullet_active );
dbScaleObject ( bullet_active, 50, 50, 50 );
dbPositionObject ( bullet_active, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() );
dbSetObjectToCameraOrientation ( bullet_active );
dbMoveObject left bullet_active,4
t_bullet(bullet_active-o_bullet)=80
inc bullet_active
if bullet_active>o_bullet+n_bullet then bullet_active=o_bullet
SC_SetObjectCollisionOn bullet_active
ammo(2)=ammo(2)-2
dbPlaySound ( s_gun+2 );
reload=40
endif
//minigun
if gun_active-o_gun = 3 && ammo(3)>0
dbSetObjectFrame ( gun_active, 1 ); dbPlayObject ( gun_active ); dbSetObjectSpeed ( gun_active, 10*tm_result );
dbShowObject ( bullet_active );
dbScaleObject ( bullet_active, 50, 50, 50 );
dbPositionObject ( bullet_active, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() );
dbSetObjectToCameraOrientation ( bullet_active );
t_bullet(bullet_active-o_bullet)=40
++bullet_active;
if bullet_active>o_bullet+n_bullet then bullet_active=o_bullet
ammo(3)=ammo(3)-1
dbPlaySound ( s_gun+3 );
reload=2
SC_SetObjectCollisionOn bullet_active
endif
//uzi
if ( gun_active - o_gun == 4 && ammo[4] > 0)
{
dbSetObjectFrame ( gun_active, 1 ); dbPlayObject ( gun_active ); dbSetObjectSpeed ( gun_active, 10*tm_result );
dbShowObject ( bullet_active );
dbScaleObject ( bullet_active, 50, 50, 50 );
dbPositionObject ( bullet_active, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() );
dbSetObjectToCameraOrientation ( bullet_active );
dbMoveObjectRight ( bullet_active, 4 );
t_bullet[bullet_active - o_bullet]=80
++bullet_active;
if bullet_active>o_bullet+n_bullet then bullet_active=o_bullet
SC_SetObjectCollisionOn ( bullet_active );
dbShowObject ( bullet_active );
dbScaleObject ( bullet_active, 50, 50, 50 );
dbPositionObject ( bullet_active, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() );
dbSetObjectToCameraOrientation ( bullet_active );
dbMoveObjectLeft ( bullet_active,4 );
t_bullet(bullet_active-o_bullet)=80
++bullet_active;
if bullet_active>o_bullet+n_bullet then bullet_active=o_bullet
SC_SetObjectCollisionOn ( bullet_active );
ammo(4)=ammo(4)-2
dbPlaySound s_gun+4
reload=8
}
endif
endvoid
void handlemonster()
{
for ( id = O_bullet; id <= O_bullet+N_bullet; id++ )
{
SC_SetObjectCollisionOff ( id );
}
++ticker_monster;
if ( ticker_monster > o_monster+n_monster) { ticker_monster = o_monster; }
dbSetVector3 ( 6, dbObjectPositionX(o_player)-dbObjectPositionX(ticker_monster), dbObjectPositionY(o_player)-dbObjectPositionY(ticker_monster), dbObjectPositionZ(o_player)- dbObjectPositionZ(ticker_monster));
dist[ticker_monster-o_monster] = dbLengthVector3(6);
if (dist[ticker_monster-o_monster]>500)
{
dbHideObject ( ticker_monster+1000 );
}
else
{
dbShowObject ( ticker_monster+1000 );
}
for id=o_monster To o_monster+n_monster
if dist(id-o_monster)<500
dbSetObjectSpeed ( id+1000, 10*tm_result );
if m_health(id-o_monster)>0
dmy = dbCameraPositionY(0)- dbObjectPositionY(id);
oldx = dbObjectPositionX(id);
oldy = dbObjectPositionY(id);
oldz = dbObjectPositionZ(id);
px=ObjectPositionX(O_player);
py=ObjectPositionY(O_player);
pz=ObjectPositionZ(O_player);
dbSetVector3 ( 6, px-oldx, py-oldy, pz-oldz );
tempdist(id-O_monster)=length vecTor3(6);
collide=SC_RayCast(0,px,py,pz,oldx,oldy,oldz,id);
if collide=0 then awake(id-O_monster)=1 ; seeplayer(id-O_monster)=1;
//only attack if monster is on same level as player
if (awake(id-O_monster) == 1)
{
if abs(dmy)<100 && collide=0
//ATTACK
if dist(id-O_monster)<60
if B_monster(id-O_monster)=0
health -= 5;
hurt=255
dbPlaySound ( s_attack );
b_monster(id-o_monster)=80
dbLoopObject ( id+1000, 20, 40 );
endif
endif
//RUN
//run directly To player when monster sees them
if dist(id-O_monster)>60 && dist(id-O_monster)<300
if B_monster(id-O_monster)=0
dbMoveObject id,1.5*tm_result
dbLoopObject id+1000,1,20
Turn=180-dbWrapValue(dbObjectAngleY(id)-atanfull(dbObjectPositionX(O_player)-dbObjectPositionX(id),dbObjectPositionZ(O_player)-dbObjectPositionZ(id))-180)
endif
endif
else //run around wild because they lost player
if dist(id-O_monster)>60 && dist(id-O_monster)<300
if ( B_monster(id-O_monster) == 0)
{
dbMoveObject ( id, 1.5*tm_result );
dbLoopObject ( id+1000, 1, 20 );
if tempdist(id-O_monster)<100 then seeplayer(id-O_monster)=0
if seeplayer(id-O_monster)=0 then Turn = -360+dbRnd(720)
}
endif
endif
endif
if Turn>5
dbYRotateObject ( id, dbObjectAngleY(id)+3*tm_result );
else
if Turn<-5
dbYRotateObject id,dbObjectAngleY(id)-3*tm_result
endif
endif
if B_monster(id-O_monster)>0 then B_monster(id-O_monster)=B_monster(id-O_monster)-1
if T_monster(id-O_monster)<=0
if B_monster(id-O_monster)=0
if dbRnd(50)=1
if SC_SphereSlide(0,oldx,oldy,oldz,oldx,oldy+4,oldz,r_monster,id)=0
if dist(id-O_monster)>40 then T_monster(id-O_monster)=7
endif
endif
endif
else
if T_monster(id-O_monster)>0 then T_monster(id-O_monster)=T_monster(id-O_monster)-0.1
endif
dbMoveObjectUp ( id, T_monster( id - O_monster ) - 5 );
x = dbObjectPositionX(id);
y = dbObjectPositionY(id);
z = dbObjectPositionZ(id);
collide = SC_SphereSlide(0,oldx,oldy,oldz,x,y,z,r_monster,id)
if ( collide > 0)
{
dbPositionObject ( id, SC_GetCollisionSlideX(), SC_GetCollisionSlideY(), SC_GetCollisionSlideZ());
}
SC_UpdateObject ( id );
else
{
if ( dbObjectFrame(id+1000) < 40 ) { dbLoopObject ( id+1000, 40, 60 ); }
if ( dbObjectFrame(id+1000) > 58 ) { dbStopObject ( id+1000 ); }
}
}
next id
for id=O_bullet To O_bullet+N_bullet
SC_SetObjectCollisionOn id
next id
endvoid
void handleplayer()
for ( id = o_bullet; id <= o_bullet+n_bullet; id++ )
{
SC_SetObjectCollisionOff ( id );
}
x=dbMouseMoveX();
y=dbMouseMoveY();
dbYRotateObject ( o_player, dbObjectAngleY(o_player)+x/tm_result );
dbXRotateObject ( o_player, dbObjectAngleX(o_player)+y/tm_result );
if dbObjectAngleX(o_player)>70 then xRotate Object o_player,70
if dbObjectAngleX(o_player)<-70 then xRotate Object o_player,-70
oldx = dbObjectPositionX(o_player)
oldy = dbObjectPositionY(o_player)
oldz = dbObjectPositionZ(o_player)
angy = dbObjectAngleY(o_player)
if vy=0 && jumptimer=0 then vy = vy + 10*-0.1 else vy = vy + -0.2
if dbKeyState(32)=1 then vx = vx + cos(angy) ; vz = vz - sin(angy) ; walking = 1
if dbKeyState(30)=1 then vx = vx - cos(angy) ; vz = vz + sin(angy) ; walking = 1
if dbKeyState(31)=1 then vx = vx - sin(angy) ; vz = vz - cos(angy) ; walking = 1
if dbKeyState(17)=1 then vx = vx + sin(angy) ; vz = vz + cos(angy) ; walking = 1
if ( walking == 1)
{
dbResumeSound ( s_footstep );
tick_Movement += 10*tm_result;
if ( tick_Movement > 360) { tick_Movement = 0; }
}
else
{
dbPauseSound ( s_footstep );
}
if ( ground == 1 && jumptimer == 0)
{
if ( dbSpaceKey() == 1) { vy = vy + 5 ; jumptimer = 20; }
}
x = oldx+vx*2*tm_result;
y = oldy+vy*2*tm_result;
z = oldz+vz*2*tm_result;
collide = SC_SphereCast(0,oldx,oldy,oldz,oldx,oldy+vy,oldz,r_player,o_player)
if ( collide > 0 )
{
ny = SC_GetCollisionNormalY()
if (dbAbs(ny) > 0.5f )
oldy = SC_GetStaticCollisionY()
else
x = x - oldx ; z = z - oldz
oldx = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
oldz = SC_GetCollisionSlideZ();
x = x + oldx ; z = z + oldz
endif
if ny>0.5
ground = 1
vy = 0
else
ground = 0
if ny<-0.5 then vy = -0.1
endif
else
oldy = oldy + vy
ground = 0
endif
if ground = 1 && jumptimer>0 then dec jumptimer
collide = SC_Sphereslide(0,oldx,oldy,oldz,x,oldy,z,r_player,o_player)
if collide>0
x = SC_GetCollisionSlideX()
oldy = SC_getcollisionslidey()
z = SC_getcollisionslidez()
endif
dbPositionObject ( o_player, x, oldy, z );
SC_UpdateObject ( o_player );
for ( id = o_bullet; id <= o_bullet+n_bullet; id++)
{
SC_SetObjectCollisionOn id
}
}
void handleitems()
for id=o_health To o_health+n_health
Turn Object left id,2*tm_result
dbMoveObject Up id,sin(tick)/10
next id
for id=o_ammo; id <= o_ammo+n_ammo
Turn Object left id,2*tm_result
dbMoveObject Up id,sin(tick)/10
next id
for id=o_story To o_story+n_story
Turn Object left id,2*tm_result
dbMoveObject Up id,sin(tick)/10
next id
tick += 4*tm_result; if (tick > 360) { tick=0; }
endvoid
void display_text(str as string)
if len(str)<1 then exitvoid
for id=1 To len(str)
if dbMid(str,id)="a" then dbSetSpriteFrame font_spr,1
if dbMid(str,id)="b" then dbSetSpriteFrame font_spr,2
if dbMid(str,id)="c" then dbSetSpriteFrame font_spr,3
if dbMid(str,id)="d" then dbSetSpriteFrame font_spr,4
if dbMid(str,id)="e" then dbSetSpriteFrame font_spr,5
if dbMid(str,id)="f" then dbSetSpriteFrame font_spr,6
if dbMid(str,id)="g" then dbSetSpriteFrame font_spr,7
if dbMid(str,id)="h" then dbSetSpriteFrame font_spr,8
if dbMid(str,id)="i" then dbSetSpriteFrame font_spr,9
if dbMid(str,id)="j" then dbSetSpriteFrame font_spr,10
if dbMid(str,id)="k" then dbSetSpriteFrame font_spr,11
if dbMid(str,id)="l" then dbSetSpriteFrame font_spr,12
if dbMid(str,id)="m" then dbSetSpriteFrame font_spr,13
if dbMid(str,id)="n" then dbSetSpriteFrame font_spr,14
if dbMid(str,id)="o" then dbSetSpriteFrame font_spr,15
if dbMid(str,id)="p" then dbSetSpriteFrame font_spr,16
if dbMid(str,id)="q" then dbSetSpriteFrame font_spr,17
if dbMid(str,id)="r" then dbSetSpriteFrame font_spr,18
if dbMid(str,id)="s" then dbSetSpriteFrame font_spr,19
if dbMid(str,id)="t" then dbSetSpriteFrame font_spr,20
if dbMid(str,id)="u" then dbSetSpriteFrame font_spr,21
if dbMid(str,id)="v" then dbSetSpriteFrame font_spr,22
if dbMid(str,id)="w" then dbSetSpriteFrame font_spr,23
if dbMid(str,id)="x" then dbSetSpriteFrame font_spr,24
if dbMid(str,id)="y" then dbSetSpriteFrame font_spr,25
if dbMid(str,id)="z" then dbSetSpriteFrame font_spr,26
if dbMid(str,id)="0" then dbSetSpriteFrame font_spr,27
if dbMid(str,id)="1" then dbSetSpriteFrame font_spr,28
if dbMid(str,id)="2" then dbSetSpriteFrame font_spr,29
if dbMid(str,id)="3" then dbSetSpriteFrame font_spr,30
if dbMid(str,id)="4" then dbSetSpriteFrame font_spr,31
if dbMid(str,id)="5" then dbSetSpriteFrame font_spr,32
if dbMid(str,id)="6" then dbSetSpriteFrame font_spr,33
if dbMid(str,id)="7" then dbSetSpriteFrame font_spr,34
if dbMid(str,id)="8" then dbSetSpriteFrame font_spr,35
if dbMid(str,id)="9" then dbSetSpriteFrame font_spr,36
if dbMid(str,id)="." then dbSetSpriteFrame font_spr,37
if dbMid(str,id)=";" then dbSetSpriteFrame font_spr,38
if dbMid(str,id)="-" then dbSetSpriteFrame font_spr,39
if dbMid(str,id)="," then dbSetSpriteFrame font_spr,40
if dbMid(str,id)="/" then dbSetSpriteFrame font_spr,41
if dbMid(str,id)=" " then dbSetSpriteFrame font_spr,42
dbPasteSprite ( font_spr, (id*dbSpriteWidth(font_spr))-((id-1)*2),font_y);
next id
font_y += 16;
endvoid
void display_numbers(str as string,x,y)
{
if len(str)<1 then exitvoid
for id=1 To len(str)
if dbMid(str,id)="0" { dbSetSpriteFrame ( numbers_spr, 1 ); }
if dbMid(str,id)="1" { dbSetSpriteFrame ( numbers_spr, 2 ); }
if dbMid(str,id)="2" { dbSetSpriteFrame ( numbers_spr, 3 ); }
if dbMid(str,id)="3" { dbSetSpriteFrame numbers_spr,4
if dbMid(str,id)="4" { dbSetSpriteFrame numbers_spr,5
if dbMid(str,id)="5" { dbSetSpriteFrame numbers_spr,6
if dbMid(str,id)="6" then dbSetSpriteFrame numbers_spr,7
if dbMid(str,id)="7" then dbSetSpriteFrame numbers_spr,8
if dbMid(str,id)="8" then dbSetSpriteFrame numbers_spr,9
if dbMid(str,id)="9" then dbSetSpriteFrame numbers_spr,10
if dbMid(str,id)="/" then dbSetSpriteFrame numbers_spr,11
dbPasteSprite ( numbers_spr, x+((id-1)*dbSpriteWidth(numbers_spr))-((id-1)*4),y);
next id
}
void dead()
{
for ( id = 1; id <= 180; id++ )
{
if (id < 90)
{
dbPitchCameraDown ( 1 );
dbTurnCameraLeft ( 1 );
dbPositionCamera (dbCameraPositionX(),dbCameraPositionY()-0.4,dbCameraPositionZ());
}
dbSetObjectToCameraOrientation ( gun_active );
dbPositionObject ( gun_active, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() );
dbMoveObject ( gun_active, 6 );
dbMoveObjectDown ( gun_active, 5+sin(tick_Movement)/2 );
dbMoveObjectRight ( gun_active, 6+sin(tick_Movement)/4 );
hurt -= 2;
if (hurt < 0){ hurt=0; }
dbSetSpriteAlpha ( s_hurt, hurt; }
dbFastSync();
}
}
void freeobject()
{
for (id = 1; id <= 1000; id++)
{
if dbObjectExist(id) == 0 then exit
}
return id;
}
void freeimage()
{
for id=1 To 1000
if Image exist(id)=0 then exit
next id
return id;
}
void freeSprite()
for id=1 To 1000
if Sprite exist(id)=0 then exit
next id
endvoid id
void freeSound()
for id=1 To 1000
if Sound exist(id)=0 then exit
next id
endvoid id
void tm_init()
{
int tm_last as dword
int tm_difference;
int tm_factor;
int tm_result;
int tm_timer;
tm_timer = timer();
tm_last = tm_timer;
tm_factor = 1;
}
void tm_Update()
{
tm_timer = dbTimer( );
tm_difference = tm_timer - tm_last;
tm_last = tm_timer;
tm_result = tm_difference * tm_factor;
return tm_result;
}
void KeyValue$(properties$,findname$,defaultvalue$)
findname$=lower$(findname$)
repeat
p=Instr1(properties$,chr$(13)+chr$(10))
if p>0
keypair$=left$(properties$,p-1)
properties$=Right$(properties$,len(properties$)-p-1)
else
keypair$=properties$
properties$=""
endif
p=Instr1(keypair$,"=")
if p=0
exitvoid ""
else
name$=left$(keypair$,p-1)
value$=Right$(keypair$,len(keypair$)-p)
if lower$(name$)=findname$ then exitvoid value$
endif
until properties$=""
endvoid defaultvalue$
void Instr1(searchstring$,findstring$)
l1 = len(searchstring$);
l2 = len(findstring$);
dl = l1-l2;
if (dl < l) then exitvoid 0
for (n = 0; n <= dl; n++)
{
endp=n+l2
s$=Right$(searchstring$,l1-n)
s$=left$(s$,endp-n)
if s$=findstring$ then exitvoid n+1
next n
return 0;
}