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 / Multiple DarkGDK questions

Author
Message
baconboy2
17
Years of Service
User Offline
Joined: 30th Jul 2007
Location: Liverpool, UK
Posted: 24th Oct 2009 19:30 Edited at: 24th Oct 2009 19:40
Hello all, I'm trying to learn DarkGDK (again), and am having a few problems. I'll list them below (maybe more than a few...):

- How do you make an object move around?

- How do you add a kind of cross-hair to the screen?

- How do you limit the up-and-down-camera to 180 degrees(code below) so it doesnt move beyond further along the axis when looking up? I keep doing a full circle with the camera and I find the map I'm looking at is upside down lol!




- Also, with the attached code, how do you get the camera to move left and right? Apparently the camera turns left and right using the keys, but it doenst. I jut want to strafe the camera!

- How do I show the FPS rate? Because when I use dbScreenFPS ( ); it doesnt seem to do anything..


Cheers for any help!

Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 24th Oct 2009 19:35 Edited at: 24th Oct 2009 19:38
well, simple:

1: dbMoveObject ( and for turning use if loops )
2: dbLoadImage,dbPasteImage,dbPositionImage ( dbScreenWidth/2,dbScreenHeight/2 )
3: if dbObjectRotationX < 90 or > -90 then let it go up or down.

These are simple codes and with some thinking you will get it to work ( else ask for more specific codes, got every single one of these in my own project so if you really want to copy paste code, ask for it )

and for strafe, create an int that contains the camera positionX, and when strafing add 1 or remove 1 of it and the Reposition the object.

and dbFPSScreen returns an integer. So you need to use dbText or dbPrint to print it to the screen ( and you need to convert it to a float with dbText )

Isocadia
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 24th Oct 2009 19:41
All of these questions can be answered by looking through the DarkGDK Documentation under
"The Game Creators/DarkGDK/Documentation/information"
Or by searching the forums, so please look next time.

- How you make an object move around?



- How do I show the FPS rate?



- How do you limit the up-and-down-camera to 180 degrees



-how do you get the camera to move left and right?



baconboy2
17
Years of Service
User Offline
Joined: 30th Jul 2007
Location: Liverpool, UK
Posted: 24th Oct 2009 22:24
To be honest, I read all the documentation, and I didn't understand it, as I am not a born programmer, I searched through the forums, and the only similar cases were in DBPro.

Now, I'm still unsure how to implement these into my code

- Got the object to move, thats fine now thanks.

- @ Isocadia: I can't seem to find the command "dbPositionImage ( dbScreenWidth/2,dbScreenHeight/2 )" anywhere. Unless that was a note version?...

- How do you limit the up-and-down-camera to 180 degrees - "check the camera angle using the internal commands and then if they are out of range reset them"................How?

Cheers guys!

Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 24th Oct 2009 22:50
I don't think there is a PositionImage function, I believe if you are looking to use moving images you would use the sprite functions instead.

To limit the camera to 180 degrees, you would do is look at the Y variable you are using for the rotation with an if statement like this:

this will make it so that the farthest it will look is straight up and straight down, and not go upside down.

I am not smart. I am not powerful. I am just a guy. I am strengthened through my faith.
baconboy2
17
Years of Service
User Offline
Joined: 30th Jul 2007
Location: Liverpool, UK
Posted: 25th Oct 2009 00:43
Right, I got the crosshair to work. Thanks Isocadia and Ultimate_H!

Thinking about it now, the camera is going to be a 3rd person, in the style of GTA4, just over the right shoulder - but thanks for the restriction help anyway!

For the FPS thingy, would the code just be this?


Cheers

heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 25th Oct 2009 01:16 Edited at: 25th Oct 2009 01:20
To show the fps use this:


If you get a buffer overrun problem use this code instead:


What the wsprintf command does is basically it puts "FPS:" into the czText variable. And then %d part of it just tells the computer to take the first integer in the argument list (which in this case would be dbScreenFPS) and add it onto the previous string of "FPS:". So if you removed the dbScreenFPS() argument then it would only display "FPS:" but if you leave it then it will display "FPS: 60" (Depending on the current FPS).

Your bedtime story is scaring everyone
If found my very own Fail!: http://cheezburger.com/View.aspx?aid=2712171776
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 25th Oct 2009 01:18
the code would be this:

or similar.

I am not smart. I am not powerful. I am just a guy. I am strengthened through my faith.
baconboy2
17
Years of Service
User Offline
Joined: 30th Jul 2007
Location: Liverpool, UK
Posted: 25th Oct 2009 01:41
Ok, thanks a bunk Ultimate_H

Sorry Heyufool1, your one was just a bit too complicated for my inexperienced mind! PErhaps one day... Thanks anyway.

Now, next question -

I want to crack character movement, and I'm unlikely to do it on my own...

This is what I've got so far -


What happens at the moment is that the animation loop keeps going on. What I need to happen is:
- Use WASD as direction keys. (For scancodes, W is 18, A is 31, S is 32 and D is 33)
- The animation only plays when the key is held down.
- When the character moves backward, the animation is reversed. I know that is done by making the speed negative, but I cant seem to influence the change from positive to negative through backward movement.
- Unless this is being too ambitious, when the player presses either left or right, is it possible for the character to turn just 90 degrees in that direction?

Cheers all!

wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 25th Oct 2009 03:14
pretty simple code, just using classes because it's OH SO CLEAN!

also i noticed a few bugs, but it should help you ALOT.


dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 25th Oct 2009 04:18
Quote: "If you get a buffer overrun problem use this code instead:"


How would that prevent buffer overrun? Also, use sptrintf() rather than wsprintf(), as the latter expects a wchar_t*. If you want buffer overrun safety then use sprintf_s().


Quote: "dbText(0, 0, "FPS:");
dbText(15, 0, dbStr(dbScreenFPS()))
"


Do NOT use this code, it will cause a memory leak that will be very hard to track when your app slows down exponentially and eventually crashes. Use heyufool1's first code snippet(except with the correct function), as it avoids this issue and is more flexible.

Lastly, instead of using magic numbers like 17, 31 etc for the key scancodes, use the actual macros that define them, as seen in dinput.h, then you can use DIK_W, DIK_A, etc.

baconboy2
17
Years of Service
User Offline
Joined: 30th Jul 2007
Location: Liverpool, UK
Posted: 25th Oct 2009 13:50
Quote: "
Use heyufool1's first code snippet(except with the correct function), as it avoids this issue and is more flexible.
"


@ Dark Coder - What is the correct function for that? I don't really understand what you mean there...

Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 25th Oct 2009 14:59
He's talking about this:
Quote: "
char czText[256];
wsprintf ( czText, "FPS: %d", dbScreenFPS ( ) );
dbText ( 0, 10, czText );
"


It avoids the issue of the memory leak by putting the return from "dbScreenFPS()" into a memory location, instead of losing the space to a nonexistent variable.

I am not smart. I am not powerful. I am just a guy. I am strengthened through my faith.

Login to post a reply

Server time is: 2024-11-20 11:28:21
Your offset time is: 2024-11-20 11:28:21