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 / Games & Graphics in C++ book by Tony Gaddis

Author
Message
coldworker
14
Years of Service
User Offline
Joined: 27th Sep 2010
Location:
Posted: 14th Oct 2010 19:12
Has anyone else used this book? We are using in our C++ class, and I am honestly so lost. I was wondering if there was another book that I could buy, that would help me with the coding. Right now, we are in chapter 6 loops. I understand how the loops work, but neither the teacher or the book are very helpful. It seems like the book just doesn't go into enough detail with the chapter subject, and then wants you to be able to write the exercise programs with no problem. I was just wondering if there was a better book for the GDK library, or a place where I could learn more about the GDK library, so I won't be so lost. Thanks.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 14th Oct 2010 20:47 Edited at: 14th Oct 2010 20:50
Are you lost with Dark GDK or lost with C++? (Loops are actually C/C++ language elements.)

I don't personally know the Gaddis book but I've met several people on this forum using it and so far there was no serious complaint about it. AFAIK there is no other book available about using Dark GDK. There is only the GDK help file and the tutorials that come with it (and reading this forum).

If you want more info about C++ there are language reference sites on the internet:

http://www.learncpp.com/
http://www.cplusplus.com/doc/tutorial/

You could also get some kind of "programming for beginners" book, preferably one with examples, if such book exists (I only know reference-type editions with not much practical exercises). It's sad that your teacher is not helpful. Even if the book does not fully explain everything it would still be quite usable with good teaching.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Oct 2010 20:55
First, how much programming knowlege do you have?
Second, ask a specific question and someone will answer it.
I've not read that book, but there are so many books out there that can teach you C++ that you can't throw a rock on the internet without hitting one.

I can help you, but I need to know where you are programming wise and what subject you need help with.

The fastest code is the code never written.
coldworker
14
Years of Service
User Offline
Joined: 27th Sep 2010
Location:
Posted: 14th Oct 2010 21:22
Thanks for the fast replies. To be honest, I am lost with both, the GDK, as well as the C++ side of coding. I have a little bit of Visual Basic knowledge, and some Rapter, and Alice programming, but I think the biggest thing is, I know how the program should work, it is just figuring it all out. I have written psuedocode, but that doesn't seem to help, as I end up confusing myself.

Right now, we are going over loops, and the exercise in the book wants us to write a program that uses a loop to cover the entire screen with bricks (looks like a brick wall). The book gives an example of the while loop, but has the program randomly placing the bricks on the screen. I understand how the while loop works, I am having trouble with actually writting the code. At this point I am really discouraged with learning C++, and I'm concerned with whether or not to continue with trying to learn programming all together.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Oct 2010 21:41
You say you understand how a while-loop works. Tell me, do you understand this code:


I declared an integer with "int" and initialized it to a value of 0.
Next we have the while-loop encapsulated with {}. These {} mean that everything inside them is part of that while-loop.
Inside the while-loop I told GDK to put text"Here" at "x,y" coordinates LoopNumber,LoopNumber.
Next I incremented LoopNumber.
Each time the process comes to the '}' it will check the value of LoopNumber and if it's less than 10 it will go back to the top '{' and continue processing like before. Once LoopNumber is 10 (or greater) when the process reaches the '}' it will go past to the next process which brings me to the next line of code.
dbSync() tells GDK to render the scene.

The code snipet above will not work on it's own, it has to be within the declaration that GDK gives when you create a new program.

Is any of that unclear? What else do you have questions about?

The fastest code is the code never written.
coldworker
14
Years of Service
User Offline
Joined: 27th Sep 2010
Location:
Posted: 14th Oct 2010 22:22
@Hawkblood

Thank you for your timely responses. I understand the snippet of code you sent, when I wrote the code, the word Here copied over itself 10 times, moving towards the right hand corner (not sure if that is easy to understand).

The next question would be how do you get each "here" to line up side by side.

ex. Here Here Here Here...and so on.

I understand that LoopNumber, LoopNumber, represent the x and y coords, but how would I set it up if I were to draw a brick, using dbBox so that all the bricks were lined up to look like a brick wall?
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 14th Oct 2010 22:27
If there is an example which randomly places bricks on the screen, then I suppose you already have a method for displaying bricks at certain coordinates. Now all you need to do is figure out the coordinates, since they will not be random this time.

Questions you should ask yourself: What's the size of one brick? I suppose it's a sprite or an image, so it should have a width and height. How many of them do I need to cover the screen? How many rows and columns of bricks? If you want to place a brick next to the other, what will be the coordinates? E.g. if the first brick is at (0,0) then the second should be placed at (width,0) the third at (2 x width,0) and so on until you have a row of them on the screen. I found that for coordinate calculations, it helps if you make a drawing on paper. Once you have an idea of the coordinates, it is easy to translate it into one or two incremented loop variables. If you need rows and columns, that will be two nested loops. (It could be done with one with some extra calculation but nesting is easier.) Now I've confused you even more or helped somewhat?

I wanted to say something in my first post, then I edited it out but in the end I can't resist saying it. I don't think the book expects you to solve the exercises "without problem" because there is no such thing. No matter how advanced you are, there will always be something in your next program that will give you headaches. Figuring it out is all the fun. Don't give up.
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 15th Oct 2010 09:42
To add onto what Mireben said, and simplify it a bit in case it was confusing. Try using just one for loop with a variable 'x'. When you draw your brick you can use the 'x' variable to set your 'x' coordinate of the brick with some simple multiplication (the width of the brick). If you can do that you now have 1 row, and to get the rest it is just a matter of adding another 'for loop' for your 'y' axis.

Hope that helps a little, and hope I didn't just completly give you your answer since it is a class and the most fun part(and tormenting part) of programming is the problem solving.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 15th Oct 2010 15:59
@coldworker
To get them to be side-by-side simply don't change the Y-coordinate.
dbBox() uses 2-XY coordinates. One for the upper left and the other for the lower right. This is the minimum dimensions required to be known to define a box. So if you wanted a box with the UL corner at 10,10 with a size of 5x5 you would write:
dbBox(10,10,15,15);
or
dbBox(10,10,10+5,10+5);
With this one I seperated the 5s out of the last XY to illustrate the fact that you could use variables like this:
int x=3,y=7,sx=5,sy=10;
dbBox(x,y,x+sx,y+sy);

These examples are very simple graphics. You should read the help to get an understanding of how each command works. Sorry to say, but not all commands are listed and even with the ones that are listed, not all of them have good explainations.

I would like to get an assesment of your knowlege base. Do you understand variable types; how to declair them and what they can do? Like:
int
char
byte
float
double
long
short
? For simple programming, you really only need the first 4.
Do you know key words like:
while
for
if
else
new
delete
? For simple programming, you won't need new or delete.

The fastest code is the code never written.
coldworker
14
Years of Service
User Offline
Joined: 27th Sep 2010
Location:
Posted: 16th Oct 2010 17:19
@Hawkblood

I understand some of the variable types:

int - whole numbers only, no decimals or fractions. Can use integers. (eg. 1-100, -1 - -100)

float - uses decimals. (eg. 1.0, 3.9, 100.10)

double - both whole or floating.

while - pretest loop, test statement before it executes.

for - count controlled loop.

if - if statement is true, do this.
(eg. if (raining outside) play video games.

else - used with if expression, if statement is false, do this instead.
(eg. if (raining outside) play video games, else go outside and play.

That is what we have gone over so far.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 17th Oct 2010 02:38
So what do you need help with? If you know the basics then it's just a matter of putting them together to do what you want.

The fastest code is the code never written.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 17th Oct 2010 17:49
Quote: "double - both whole or floating."


Yes but you can say the same about "float" too. The difference between float and double is that double can hold longer numbers, so you can make more precise calculations with it.
coldworker
14
Years of Service
User Offline
Joined: 27th Sep 2010
Location:
Posted: 21st Oct 2010 16:00
@HawkBlood
Sorry it took so long to respond. School has been crazy. Well, I figured out what I needed to do. I had gotten the brick wall up, but couldn't figure out how to make every even numbered row to shift over 1/2 of a block. I was trying to divide the dbBox dimensions by half. However, I had to go back and put an if statement in and the the program to divide the rows in half.

That was throwing me off. But, thanks for all the help you and the others gave me. I really appreciate it all.

@Mireben - yeah, I forgot to write that about double. But thanks for adding that!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 21st Oct 2010 20:43
In case you need it, here is an easy way to find out if a number is odd or even: check the remainder of dividing by two. ("Modulo" operator.)



If the result is zero, the number is even, else it is odd.
coldworker
14
Years of Service
User Offline
Joined: 27th Sep 2010
Location:
Posted: 22nd Oct 2010 00:33
@Mireben

Yeah, that was the hard part, remembering to use the % sign. Had to search through several pages on the net to find that out. Thanks for all your help.

Login to post a reply

Server time is: 2024-11-19 16:23:25
Your offset time is: 2024-11-19 16:23:25