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.

DarkBASIC Discussion / C++ Basic programming help

Author
Message
Questions C++ basic
8
Years of Service
User Offline
Joined: 28th Jun 2011
Location: United States
Posted: 28th Jun 2011 22:19
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 first or second loop, can anyone help?

AfterLife
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Jun 2011 17:31
OK first off, please put your code in
It's simple, highlight your code and hit the "code" button in the forum text edit box.

Secondly, this forum here is for DBC users (Dark Basic Classic). You will get more responses if you post on the Dark GDK board

Thirdly, why name yourself after this posts title? Why not give yourself and awesome name like Cardboard Carnage or Metabolic Meltdown, lol

And last of all, I don't understand your question

TheComet

Van B
Moderator
17
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Jun 2011 18:06 Edited at: 1st Jul 2011 11:01
I would either change that to a grid system, as your most likely to need an array to hold the 'board' anyway, I would do that from the outset.

I think it might just be the for...next loop causing confusion. If you use an integer X and Y, and multiply the position, you might have more convenient control over things. Like:



And with that, a simple booleon flag to offset on X...



That ''xoff = 1-xoff;'' bit will swap xoff between 0 and 1.

Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2019-12-10 15:32:26
Your offset time is: 2019-12-10 15:32:26