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 / Strange gdk problems

Author
Message
kmation
13
Years of Service
User Offline
Joined: 7th Oct 2010
Location: US
Posted: 7th Oct 2010 23:30 Edited at: 7th Oct 2010 23:54
hey guys, been a long time since i came here, but I've regained my interest in game development and started using darkGDK
i've learned a lot already, but am confuse by the errors i am getting from a seemingly flawless code:





the error i am receiving:
1>c:\users\kevin\documents\visual studio 2008\projects\jump\jump\player.cpp(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

the function 'gravity()' is defined in the header file 'player.h'

i cant make heads or tails of this problem... could anyone please help me out?

"I'm sick and tired of following my dreams, I'm just gonna ask them where they're headed and meet up with 'em later"
-Mitch Hedberg
kmation
13
Years of Service
User Offline
Joined: 7th Oct 2010
Location: US
Posted: 8th Oct 2010 00:55
I now realize there should have been an int before player::gravity, but even so my program still crashes when i try to run it

my main.cpp is as follows



heres player.cpp


and heres player.h


this program compiles but simply runs as a black screen that causes the program to crash. can anybody please offer me some advice?

"I'm sick and tired of following my dreams, I'm just gonna ask them where they're headed and meet up with 'em later"
-Mitch Hedberg
Manga Tiger Boy
14
Years of Service
User Offline
Joined: 24th Aug 2009
Location:
Posted: 8th Oct 2010 04:13
I noticed a problem in this line:



you tell the program to react to the collision of "plr" and "platform," but I don't see "plr" defined anywhere at all. Do you mean plr 1?

kmation
13
Years of Service
User Offline
Joined: 7th Oct 2010
Location: US
Posted: 8th Oct 2010 04:48
plr is defined as 1

"I'm sick and tired of following my dreams, I'm just gonna ask them where they're headed and meet up with 'em later"
-Mitch Hedberg
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Oct 2010 17:47
Your player::fall function moves the sprite until a collision happens. But you won't see anything on the screen because the screen would be updated by dbSync() which is in the main loop. If you don't return to the main loop to update the sceen, then the screen will be black. At least include a dbSync inside your for loop, but I would vote for a reorganization of the code: move the sprite in the player::fall function just once, then return to the main loop and check for collisions there. Something like this:



In this case, "vel" will be either a static variable of the player::fall function or (better) a data member of the player class.

Another problem is that your fall function may well get into an endless loop. dbMoveSprite moves the sprite in "the current direction". I'm not sure what the default "current direction" is but supposing that it tries to move to the right, and you give velocity a negative value, then the sprite will move to the left, and it will never collide with your other sprite. Try to fix the screen update first, then check how the sprite moves and correct the direction and velocity accordingly.

By the way, this command looks rathert strange:
. Why not this?

Login to post a reply

Server time is: 2024-06-30 11:49:07
Your offset time is: 2024-06-30 11:49:07