Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Few questions

Author
Message
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Jul 2009 14:28
i have some questions about DarkGDK, working on a game but having alot of troubles..

1. which is the best and the easiest program to make 3D objects that can be easily used in the DarkGDK

2. is there a way to delete the terrain?


3. "dbLoadObject()" loads an object into the screen, how can i position this object on the terrain?

4.i have created a game which build terrain and then i can move camera around (similar to the one in the tutorials), but i changed the "while ( LoopGDK())" to "while (1)", and made the esc key opens a menu:
(LoadMenu loads 4 images (menu background and the 3 buttons (options - resmue - exit game)))
this function isnt working at all, it is suposed to show the mouse and display the 3 buttons with the background, it shows the mouse
but it doesnt show any sprites, the function is wrong?

5. is there a place to see all functions in the DGDK? the tutorials doesnt show all of them, also it shows really little info about 3D objects :/
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Jul 2009 14:31
@ question 4: i also tried dbSprite() to show the menu, but no use, nothing is appearing on the screen
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 8th Jul 2009 17:01
5. Start->All programs->The game creaters->DarkGDK->Documentation->Information

Thats where it is for me anyway.
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 8th Jul 2009 19:35 Edited at: 8th Jul 2009 19:37
1. I use Anim8or to make the model because of the simple UI. Then I import the model into Milkshape 3D to make groups for the UV, and then after I UV and make the texture I export the final model from Milkshape 3D in .X format which is the 2nd best choice for a model in Dark GDK. (.dbo is generally the best format)

3. To position the object on the terrain you can either just use dbPositionObject (...) to the appropriate spot.

4. Try putting dbPasteImage for your menu images in the loop, and include a dbSync ( ) as the last line of your loop (After the dbMouseClick decision structure). The dbSync ( ) command redraws the screen.


Use Google first... it's not rocket surgery!
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 8th Jul 2009 19:42 Edited at: 8th Jul 2009 19:48
Quote: "1. which is the best and the easiest program to make 3D objects that can be easily used in the DarkGDK"


This is a list of (free )programs which I think can all export to DarkGDK in various shapes and forms. The '?' denotes features that I am unsure of their compatibility with DarkGDK.

Blender 3d ( Mesh / Animation / Texturing )
Wings 3d ( Mesh / Texturing )
Anim8or ( Mesh / Texturing / Animation? )
Sketchup ( Mesh? / Texturing? )
Truespace ( Mesh / Texturing / Animation? )

Quote: "3. "dbLoadObject()" loads an object into the screen, how can i position this object on the terrain?"


dbPositionObject( ID, x, y, z );

Quote: "4.i have created a game which build terrain and then i can move camera around (similar to the one in the tutorials), but i changed the "while ( LoopGDK())" to "while (1)", and made the esc key opens a menu:"


It looks like you aren't calling dbSync( ) anywhere in that while loop, that could be a problem. dbSync( ) draws the contents of the screen.

Quote: "dbScreenWidth()/2)+28.57142857142857142857142857143"

Is that much precision really necessary? o.0

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Jul 2009 19:52
question 1 is solved, thanks for giving me some names.
question 4 is solved, thanks guys didnt notice that there isnt a dbSync()
question 3 is solved, thanks phosphoer and heyufool1
question 5 is solved, thanks matty

looking forward to know if its possible to delete terrain, and if its not, i think the only way to make levels for the game is by making one big terrain including all levels, right? :/
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Jul 2009 22:41


that condition never becomes true, anything wrong with it? O_o
Krisacz
15
Years of Service
User Offline
Joined: 3rd Mar 2009
Location: UK, Manchester
Posted: 9th Jul 2009 00:11
try that:



I sure that symbol "&&" has higher priority than ">" or "<".
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 9th Jul 2009 00:21
Nothing is wrong with it as far as I can tell, are you sure you are actually putting the mouse within that box?

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 00:26
Quote: "Nothing is wrong with it as far as I can tell, are you sure you are actually putting the mouse within that box?"


this box is supposed to be the top left of the screen, right?, i made a break point in the condition sentence, but it aint breaking, and the condition isnt being executed



as u can see, the sprite is far from that box, but i made the box at (x1,x2,y1,y2) (0,200,0,100) to test it :S
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Jul 2009 11:22
The problem is somewhere else in your code, because your original condition is perfect. If you try with this code:



It works. I copied the "if" condition exactly as it was in your post.

Why are you putting the dbSync() inside the "if", anyway? Normally it should appear only once at the end of the loop. And why is it necessary to set the sprite priority inside the "if"? Should it have a different priority if the mouse is outside that range?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 12:11
Quote: "Should it have a different priority if the mouse is outside that range? "


ye, kinda

i realised that the problem is in the game window it self, i tested the example u gave me, it worked fine.



added a break point at dbsync and it worked, the "if" condition is is always false.


i have these 2 lines in the game code, that changes the coords or something?
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Jul 2009 12:24 Edited at: 9th Jul 2009 12:34
If you put a breakpoint on dbSync in the above code, it will stop in each loop regardless of the "if", because there are no brackets, so the "if" condition is one line only and dbSync is always executed. If you want a breakpoint within the "if", then add brackets:



And a breakpoint on dbPlaySound, although the sound itself should be enough to indicate that it executes.

EDIT: I believe the coordinates shouldn't change when the window is maximized, but if the game and screen resolution are different, the coordinates are "stretched" along with the picture.

If you still can't get it working, I suggest you post the whole code (with more explanation on what is the expected result).
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 12:24

works


doesnt work


(both testing inside a while loop)
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 12:27
Quote: "If you put a breakpoint on dbSync in the above code, it will stop in each loop regardless of the "if", because there are no brackets, so the "if" condition is one line only and dbSync is always executed.
"


i know this dude but i wanted to say that the loop is being executed =P
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Jul 2009 12:38
Well, I tested this with maximized window and sound and it still works. The only thing is that the dbPlaySound plays always from the beginning, so if there is a little empty space in the beginning of the sound, then you won't hear it. Maybe try:



Apart from this, I'm out of ideas.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 13:00
main body



here's the whole function..



LoadMainMenu function


about the images:
1007 is the background for the options
1008-1010 are the 3 buttons options-exit-continue
1016-1018 are the same images as 108-1010 but glowing (to add an effect while the mouse is over a button.

when i start the game:
game loads
i press esc
it shows the mainmenu and the glowing "continue game" (because the mouse was in the middle when i clicked esc) and when i move the mouse around it doesnt remove the glowing image, and whereever i click it counts as clicking the resmue game button

hope its not confusing u xD
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Jul 2009 15:56
I'm sorry to say but the code is messy. It is really difficult to debug code which is not well organized. I created a few test sprites and tried to run the code and the only result I got was an endless loop, the program didn't even want to exit properly.

You shouldn't need to scatter dbSync() everywhere in the code, try to code so that you need as few of this command as possible. You shouldn't need to re-load the images from disk every time you display the menu. It's not necessary to delete the sprites (although you can, question of taste) but it's enough to hide them, since the menu might be needed again any time. It shouldn't be necessary to use "while" loops to test for mouse coordinates, or several tests for the Escape key in the main menu function when one would be enough, it is strange to compare mouse coordinates with floating point numbers when screen pixels are integers, and so on. I don't even understand how the menu appears at all since you seem to put all button sprites at the same coordinates in the beginning of the DisplayMainMenu function, so they overlap each other.

Instead of trying to find the bug in this code, I re-wrote the whole thing. Code below. I don't say that it's the best solution, I just wrote this as quickly as possible, to show you how I would approach the task of displaying the menu. I didn't know the size of your sprites so you may need to adjust the pixel values.

Since programming style is a question of personal taste, you don't need to accept this, but it is one possible solution which may be adapted to suit your program.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 17:22
Quote: "I don't even understand how the menu appears at all since you seem to put all button sprites at the same coordinates in the beginning of the DisplayMainMenu function"


Well, i made them all at the same point because all of them are the same size, they're just alpha channeled, so instead of positioning them in the code i can do it on photoshop, which is a bit easier
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 9th Jul 2009 17:49
Quote: "Well, i made them all at the same point because all of them are the same size, they're just alpha channeled, so instead of positioning them in the code i can do it on photoshop, which is a bit easier "


That will ruin any dbSpriteHit / dbSpriteCollision checks you do, just so you know.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 18:23
Quote: "That will ruin any dbSpriteHit / dbSpriteCollision checks you do, just so you know."


these functions are useless for my game
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 19:53


Ok, all images are loaded, all sprites are loaded, and all of sprites are hidden (did that in another part of the program (set up part))

this code is better than my last one... and easy to understand i guess, but simply doesnt work, the only working part of it is


if u see a problem in this code, please tell me, instead of writing a new one
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 19:57
the problem is still the same. the coords aint working

something i didnt mention is that

works, but the Y condition is having problems.
and also, the problem happens only in this project, i tested the example u game me before and worked fine (about printing text when mouse is in the box), but here, the Y axis is screwed up for some reason
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 20:16
in the code i posted there's a little mistake


used MX instead of MY, anyway, this didnt solve the problem
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Jul 2009 20:40
In these lines:



In the second part, I think you need MY, not MX.

Also I'm not sure that the dbHideSprite calls at the end are in the good place. First you display a "glowing" sprite and then immediately hide it again. It will probably flicker, or just not show up. But you can test this when you have managed to get those lines executed. Does the change from MX to MY help?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 9th Jul 2009 20:46
changed and it didnt help (check my last post)

oh and also, ur point is right, i shouldnt hide them there.

that is what happens atm so far:

1- game run
2- i press esc
3- it shows the main menu (no buttons glowing, even through the mouse is in the middle of the screen which should make the middle button (resume) glow.)
4- where ever i put the mouse, where ever i click, nothing happens, unless i press esc.
5- add breakpoints at the first function in each Y axis condition and no breakpoint is triggered.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Jul 2009 22:19 Edited at: 9th Jul 2009 22:20
I did see your last post, but there are two mouse variables in each of those lines and in that post, you corrected only the first. Change the second comparison to MY too:

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 10th Jul 2009 00:18
Quote: "I did see your last post, but there are two mouse variables in each of those lines and in that post, you corrected only the first. Change the second comparison to MY too:"


Well not really i posted the wrong line


anyway, i still cant figure out the problem...its weird, im thinking of a new way to do, so instead of putting all alpha channeled images in 1 place ill give each button its each size and position them

Quote: "That will ruin any dbSpriteHit / dbSpriteCollision checks you do, just so you know."


^
|
took the idea from here, ill hide the mouse, and display another pic at the mouse position, so if this image hits the buttons it glows and if i click while glowing it will do whatever its supposed to do, i hope i wont need any X-Y coordinates in this situation, anyway ill do it tomorrow and i hope it will work.

anyway, i have a question, i have another question (yea yea i ask alot xD, well i got the dark GDK few days ago, and tutorials doesnt show everything) so my question is, i have loaded an object into my game, and i also have a Sprite that looks like a "+" in the middle of the screen (which is the mouse position), how can i hit this object by clicking the mouse? (at the moment the mouse click just plays a shoot sound), i just want the idea of this, not a code, -still looking for a solution for the first problem -
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 10th Jul 2009 00:42
Use dbPickObject( ), look up the documentation for it

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 10th Jul 2009 13:10 Edited at: 10th Jul 2009 13:42
How can you post the wrong line if it's copy-paste from your program? Do you retype the code you post?

I only know that if I take your new DisplayMainMenu function (the one you posted at 9th Jul 2009 18:53) and change those MX-es to MY-s then it actually WORKS. (Apart from the flickering that I already mentioned, but that's only a question of where you place the show/hide commands, and I already gave you an example for that.) I know that one's eye can skip over such typing mistakes thirty times without noticing, so check those lines just once again before you discard the coordinate check method completely.

Anyway, from this point you can certainly figure this out yourself. You can also go a different way with sprite collision if it feels more convenient. That has the advantage that the position of the menu buttons is not so much hard-coded.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 10th Jul 2009 21:27
great. i rewrote the code and now my main menu works as it should now, pretty good

thanks all of you for the help and ideas.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 14th Jul 2009 11:32
Quote: "Use dbPickObject( ), look up the documentation for it "




should randominteger's value now be the ID of an object which i see it in the middle of the screen?
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 14th Jul 2009 20:59 Edited at: 14th Jul 2009 20:59
If the last two parameters are zero, chances are that it won't return anything. Those mean the range of object ID numbers to check. For example, if you created objects with ID numbers from 1 to 112, then use 1,112 instead of 0,0.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 14th Jul 2009 22:37 Edited at: 14th Jul 2009 23:40
i didnt even know what are the last 2 parameters for, so they are for the ID range of the object? or the id range of the image on the screen?
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 15th Jul 2009 01:51
An easier way to do this, make a 1x1 sprite, position it at the mouse x and y, then do a dbSpriteCollision() check. Then if they are colliding it will equal 1 and you can do all your math there.

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 15th Jul 2009 08:57 Edited at: 15th Jul 2009 09:02
Quote: "i didnt even know what are the last 2 parameters for,"


It is explained in the Dark GDK help, look it up:

dbPickObject
This command will return the Object Number of the closest object at the specified screen coordinates. The objects that are tested against the 2D coordinate are only those within the Object Start and Object End range in order to speed up specific tests. If no object exists at the coordinate, a value of zero is returned. If an object number is returned, additional data will be generated and stored internally. This extra data can be retrieved using the dbGetPickVector and dbGetPickDistance commands.

Syntax
int dbPickObject ( int iX, int iY, int iObjectStart, int iObjectEnd )

Quote: "do a dbSpriteCollision() check"


I think that works only for sprites, not for 3D objects.

Yet another way to hit the object would be raycasting collision check, but dbPickObject will do the job as well.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 15th Jul 2009 13:47
oh well thanks the dbPickObject() worked just fine.

again, thanks for the info
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 15th Jul 2009 23:00 Edited at: 15th Jul 2009 23:01




giving me this error "'=' cannot convert from 'const char [21]' to 'char [80]

what is the problem here?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Jul 2009 23:12
Try

strcpy (colonel.path, "Media\\3D\\Colonel-X.X");

In C++, unless you're using std::string, you don't assign a string to another string. You have to copy one string to another.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 15th Jul 2009 23:51
thanks for info dude, that worked
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Jul 2009 05:17
I think i know what the problem is for your mouse checks.

Basically, the compiler can't really interpret how you want your statements to be read, like this:
if(a < b && c > d && e != f

That could be read as
if(a < (b && ( c > (d && ( e != f)))))
or any other combination of parentheses. To prevent any confusion, its good to put in parantheses.

if ((a<b) && (c>d) && (e!=f)

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 16th Jul 2009 12:47
well whatever was the reason, im sure that dbSpriteCollision is better than giving coordinates.

new question: since there is a function to point camera to an object, is there a function to point an object to the camera?
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 16th Jul 2009 17:40
Quote: "Basically, the compiler can't really interpret how you want your statements to be read, like this:"


Sure it can.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 18th Jul 2009 13:45 Edited at: 18th Jul 2009 13:55
i created some objects and positioned them around the terrain, when i shoot them, i want their health to be reduced, the objects health / ID etc are in a structure:

so when i create an object, it goes like this:

i want to make a function wich reduces health from an object by giving the function the ID of the object, hope that make sense lol, here's an example:



How should ReduceObjectHealth() function look like?
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 18th Jul 2009 18:09 Edited at: 18th Jul 2009 18:09
The creature you create when you call CreateCreature() gets deleted as it goes out of scope when that function ends. Define all of your creatures either in an array or in a vector.



Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 18th Jul 2009 18:53 Edited at: 18th Jul 2009 18:54
CreateCreature works fine, oh well but for some reason when i call it the camera go to 0,-130(X,Z) and about the example, i dont get it at all

saving them in an array, well never tried these stuff before, but should it look like this?:
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 18th Jul 2009 20:15 Edited at: 18th Jul 2009 20:15
Here is some info on arrays: http://www.cplusplus.com/doc/tutorial/arrays/

No, the array will not resize itself, which is why I suggested using a vector. They are dynamic and you can add and remove stuff.

Here is some info on vectors: http://www.cplusplus.com/reference/stl/vector/

Your create creature function does work as in it creates a creature and shows an object on the screen, but the creature that you create gets deleted every time and there is no way to access anything inside of it like health and the id number.



Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 18th Jul 2009 20:21
Awesome, now i kinda get it, reading about vectors atm, well i've never heard of them anyways

thanks alot dude.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 18th Jul 2009 20:24
@ dark coder
cool, ive never seen a page like that before, it'll definitely be useful.

so this:
a < b && c > d && e >= f
is interpreted the same as this?
(a<b) && (c>d) && (e>=f)
:\ i didnt know that, ignore mah advice hassan

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 18th Jul 2009 20:28
Even though order of precedence is solid, it often behooves the programmer to use the parenz anyway. It makes the code more readable and more understandable as to the intent. Adding extra parenz where not explicitly needed does not add to the code size.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-11-20 11:31:05
Your offset time is: 2024-11-20 11:31:05