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 / Noob questions...

Author
Message
Unseen Machine
13
Years of Service
User Offline
Joined: 23rd Jul 2010
Location:
Posted: 25th Jul 2010 19:28
So i just started with the GDK. My C++ skill level is low. Though i have a strong skills in BASIC.

I have a few questions. So if you'll be willing, i'd be most grateful.

I have set my screen size to 1024,768.
I have a paddle, you can move it left and right.

When i move it right it carries on and disapears. The control for it only allows movement if the paddles x variable is < 1024-50 ( the paddle is 50 ). But the right wall does not seem to be at 1024! Do i need to set a pixelsize or something? Or is there some other reason.

Also, as i am new to this language, if you have any comments on how to improve my code, or if i should be doing something a differant way, please TELL ME!!

//Breakout v.01 - By Unseen Machine

#include "DarkGDK.h"

//Global Variable declerations

//Camera
int camx = 0;int camy = 50;int camz = -100;

//Paddle variables
int px = 300;int py = 400; int oldpx;int oldpy;

//Ball variables
int bx;int by;int bdirect;int ballflag = 1;


void ball (void)
{

if (ballflag = 1)
{
bdirect = dbRND(4);
bx = 512;
by = 300;
ballflag = 0;
}

if (bdirect = 1) // Up Right
{
if (bx < 1010 && by > 0)
{
bx += 2;
by -= 2;
}
}

if (bdirect = 2) //Down Right
{
if (bx < 1010 && by < 768)
{
bx += 2;
by += 2;
}
}

if (bdirect = 3) // Down Left
{
}

if (bdirect = 4) // Up Left
{
}

return;
}

void usercontrol (void)
{

if (dbLeftKey () > 0)
{
if (px>0)
{
oldpx = px;
px -= 5;
}
}

if (dbRightKey () > 0)
{
if (px < 700-50)
{
oldpx = px;
px += 5;
}

}

return;
}


void drawgameobjects(void)
{

dbInk(dbRGB(0,200,0),dbRGB(0,0,0));
dbCircle(bx,by,8);
dbInk(dbRGB(0,0,0),dbRGB(0,0,0));
dbBox(oldpx,py,oldpx+50,py+20);
dbInk(dbRGB(0,0,200),dbRGB(0,0,0));
dbBox(px,py,px+50,py+20);

return;
}


// the main entry point for the application is this function
void DarkGDK ( void )
{

//Game window Settings
dbSetWindowSize (1024,768);
dbSetWindowTitle ("My First Dark GDK Game");
dbSetWindowPosition (30,40);

// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbPositionCamera (camx,camy,camz);

// our main loop
while ( LoopGDK ( ) )
{

//Do what needs doing
ball ();
usercontrol();
drawgameobjects();
// update the screen
dbSync ( );

}

//Bad console habits die hard!!!
//system ("PAUSE");

// return back to windows
return;
}
Bran flakes91093
15
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 25th Jul 2010 22:26 Edited at: 25th Jul 2010 22:29
Use dbSetDisplayMode(1024, 768, 32) instead. dbSetWindowSize just resizes the window, and does not change the actual resolution.

Also:

Use '=' for assignment, and '==' for comparision.

ballflag = 3;
if(ballflag == 4) { ... }

This, 'if(ballflag = 3) { ... }' will set ballflag to 3 instead of checking it, and that statement will always be true.

“C++ : Where friends have access to your private members.”
-Gavin Russell Baker
Greg_C
14
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 25th Jul 2010 22:45
And in your code for checking to see if you are to far right you have this:



You should have this:


also use code tags
Unseen Machine
13
Years of Service
User Offline
Joined: 23rd Jul 2010
Location:
Posted: 25th Jul 2010 23:19
Thanks folks, your tips have made it work.

I'll be back with more questions soon i'm sure.
Unseen Machine
13
Years of Service
User Offline
Joined: 23rd Jul 2010
Location:
Posted: 30th Jul 2010 05:12
I have a new question, why does my sky box not load? I have tried everything, and it does not work!!!!

heres the complete programme...

http://dl.dropbox.com/u/8822351/Dark%20GDK%20-%203D%20Game1.zip

and heres the skybox code...



If i need to do something else or have just messed it up please let me know...it's driving me mad!!!

Thanks folks...UNSEEN
Unseen Machine
13
Years of Service
User Offline
Joined: 23rd Jul 2010
Location:
Posted: 31st Jul 2010 04:35
Solved it. I had the Scale values WAy too high!! i am now using 10.

Login to post a reply

Server time is: 2024-07-04 09:28:49
Your offset time is: 2024-07-04 09:28:49