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 / C++ Basic programming help

Author
Message
Questions C++ basic
12
Years of Service
User Offline
Joined: 28th Jun 2011
Location: United States
Posted: 29th Jun 2011 20:31
Hi,

Im writing a program to diplay a brick wall, problem is I cant seem to get \\\" every other\\\" row to appear to shift to the right/left. To truly look like a wall of bricks. ( is this confusing?) here is my code


#include \\\"DarkGDK.h\\\"


void DarkGDK()
{

int x,y,z;
int Max_X= 639;
int Max_Y= 479;
int width= 60;
int height= 40;

const DWORD red = dbRGB(255,0,0);
const DWORD black = dbRGB(255,255,255);


for(y = 0; y <= Max_Y; y+= 43)
{
for(x = 0; x <= Max_X;x+= 63)
{
dbInk(red,black);
dbBox(x,y ,x+ width,y+ height);
}
}

dbWaitKey();
}

I though to add this to make every other row shift the x position to -30,

** if(y%2 != 0) **
{
x = -30;
}

it doesnt seem to work if I place it within the outer or inner loop, can anyone help?


AfterLife

AfterLife
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 30th Jun 2011 00:53
You have the right idea, just wrong emplimentation:



The fastest code is the code never written.
Questions C++ basic
12
Years of Service
User Offline
Joined: 28th Jun 2011
Location: United States
Posted: 30th Jun 2011 04:27
Thanks very much, I thought i might of been overthinking it. Apreciate the help!


Quote: " “When you pass by the meadows of Paradise indulge freely in it.”
They said: “O Messeneger of Allah, what are the meadows of Paradise?”
He replied: “The circles of knowlegde.”"


Afterlife

AfterLife
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 30th Jun 2011 11:31
just a quick tip: don't use dbInk like that, it's very slow, since you're not changing bricks color for every brick, just put it outside the loop:



Login to post a reply

Server time is: 2024-05-18 06:57:53
Your offset time is: 2024-05-18 06:57:53