Posted: 7th Jun 2007 22:26
Well i tooked a chance and started working on a game in DarkBasic Pro! I want it to be a simple game! The ideea is to have an arena(p.s i used the world model from the tutorials that come with DarkBasic pro, the one with the fps) and 2 space craft's that will fight in it! While working on it i came across some problems that include: Flying through the arena walls , and i don't know how i can make the enemy move and make the craft's shot... Here is the code i developed so far:
+ Code Snippet
start=1
If start=1
`First Video starts here:
   Load Animation "1.AVI",1
   Play Animation 1
   Sleep 11000
   Vid2=1
Endif
If Vid2=1
   Delete Animation 1
   `Your second Video starts here:
   Load Animation "1.AVI",2 `could be an intro!
   Play Animation 2
   Sleep 9500
   Delete Animation 2
   Vids=Finished
   cls
Endif
If Vids=Finished

endif




sync on : sync rate 100
hide mouse


set text font "arial" : set text size 16
set text to bold : set text transparent


 center text screen width()/2,screen height()/2,"SE INCARCA PROGRAMUL"

load bsp "world\ikzdm1.pk3","ikzdm1.bsp"


MusicSnd=101 : load sound "sounds\ma.wav",MusicSnd
 loop sound MusicSnd : set sound volume MusicSnd,80

SYNC ON    : SYNC RATE 300
HIDE MOUSE

load object "avion.X",1
load image "c.bmp",1
texture object 1,1


position object 1,10,10,1


 load object "enemy.x",ene
load image "ps.bmp",2
texture object ene,2
position object ene,30,10,50


POSITION OBJECT 1,0,0,-10

POSITION CAMERA 0,130,-299

DO

OLDX# = OBJECT POSITION X(1)
OLDY# = OBJECT POSITION Y(1)
OLDZ# = OBJECT POSITION Z(1)

IF UPKEY() = 1 THEN move object 1,1.5

IF DOWNKEY() = 1 THEN move object 1,-1.1

IF LEFTKEY()=1 THEN YROTATE OBJECT 1,OBJECT ANGLE Y(1)-1
IF RIGHTKEY()=1 THEN YROTATE OBJECT 1,OBJECT ANGLE Y(1)+1

IF OBJECT COLLISION (1,0)
POSITION OBJECT 1,OLDX#,OLDY#,OLDZ#
ENDIF

SYNC
LOOP


Here is a picture on how the game is:
http://zapping.evonet.ro/pics/668a523d0381af393794476b16fa0164.PNG
Posted: 7th Jun 2007 23:40
( Isn't there anyone that could help me
Posted: 8th Jun 2007 0:12
i came across some problems that include: Flying through the arena walls


Well,you can use SC_Collision dll for this.Make a search in the forum,you'll find it.
Posted: 8th Jun 2007 7:59
Well thank you ! This whas the biggest problem yet Il keep searching on how to fix those other problems 2, anyway thanx mate!
Posted: 8th Jun 2007 8:44
Neh still doesen't work! I used the dll some commands still stays put.. I made a new arena (c.x) and a craft avion.x! Well anyway here you have the project! Look for yourself...I gues i'm not smart enough ! All i wanted to do is do an arena in milkshape with 4 walls and a floor! My craft would start in the middle and then be able to move around! Thats the problem i can't make it move in thath arena

http://rapidshare.com/files/35888671/FLy_Game.rar.html Here is the project
http://rapidshare.com/files/35889146/GAME.rar.html
here is the "working" game, where the plane passes through the arena wall! I whant the plane to be moving inside the arena free, and colide with the wall not pass through them!
Posted: 8th Jun 2007 15:18
You might want to include some collision-detection code in your movement section. Something along the lines of SET OBJECT COLLISION ON <objNumber> for each of your ships, and the arena itself. Then when you move each ship, you can do a quick check using vObj = OBJECT COLLISION(<objNumber>, 0) - if your object (say, a starship) collides with anything, it will be returned in to 'vObj' variable - otherwise it will return 0.

Though I've never tried it, but you might get some instant results just using AUTOMATIC OBJECT COLLISION <Object Number>, <Radius>, <Response> - where Object Number pertains to the object you want "auto-collision-ed", the Radius refers to the distance at which you want the collision detected, and Response is the automatic response you want to see. The only response code/value I know about is '1', which means the object, upon collision, will be "backtracked" until it is no longer in collision with anything. For quick results, this might be what you're looking for.
Posted: 9th Jun 2007 23:35
right well, it looks like your arena is pretty much square...

so you just need to set boundaries like this

IF X < 0 then X = 0
IF Z > 100 then Z = 100

x being your player's x position
this will make it so that if the x co-ordinate goes past this point
it will not allow it to go any further!
you can change 0 and 100 to any value, and do it to any variable (like your Z co-ordinate for the other 2 walls)

this is just VERY simple collision
you need more advanced commands for detecting it among shapes etc.
but a quick search of the forum will yield this

also, i do not reccomend DBPro's internal collision, i haven't used it in ages, but last time i did, it was horribly slow and buggy

try other people's collision commands, and when you have more of a grip of the language, try some math collision, which is just an expanded version of what i showed you! i use this in all my games, and it is lightning fast and if you program it into a function can be very versitile.
Posted: 9th Jun 2007 23:44
Well Oki thankx guys! But yet i still have a problem ! If i create a .X Map and load it in DBPro any object in it will get stuck! Thats my biggest problem Ever....! It just makes me mad! What code is there to make the object move freeley inside it! Or another exemple! Lets say i make a road! Just a road with no borders, so a flat road! I place a .X car on it! The car gets stuck..... If i delete the road the car can move... how can i do so that the car will be aible to move on the road? A snippet o something?
Posted: 10th Jun 2007 0:21
thats because the DBPro collision commands are not very flexible
techinally, your ship is INSIDE the level
so it according to the DBPro collision commands, its colliding!
using maths collision will stop this
Posted: 10th Jun 2007 0:28
Any exemple for math coliding?
Posted: 10th Jun 2007 21:24
@zapakitul

Esti roman frate? Zi ceva in romana sa vedem.
If you don't understand what's written above, don't worry about it .
You might also consider making your own arena as separate parts and then you could use the DBPro collision commands. That's what I always do when I get these problems.
Posted: 11th Jun 2007 10:55
Dap sunt roman! And well im on allot of english boards regarding different thinkg! Its nice to see fellow romanian's here! Oki il say my little problem in romania maybe Alexb will understand! Am o problema cu colisiunile in joc! As vrea ca nava sa numai poata sa treaca prin pereti! Si de asemenea daca fac o arena in milkshape si o salvez .X directX si in ea pun un obiect tot .X obiectul nu se paote misca in ea! Hope you cand help me(and we don't get banned for speaking in a nother language...)