|
It might help if you described the trouble.
|
|
|
|
|
Apologies, when I compile it I get errors for the
(Circle1=0; Circle1<15; Circle1++)
line of code saying:
In function 'displayFunction':
error: incompatible types when assigning to type 'int[20]' from type 'int'
warning: comparison between point and integer
error: lvalue required as increment operand
|
|
|
|
|
Chidori-chan wrote: error: incompatible types when assigning to type 'int[20]' from type 'int'
Well, of course. Circle1 is an array of integer, you can't compare an array of integer to a simple int. What are you trying to achieve here exactly ?
|
|
|
|
|
Ultimately I'm making a game in which you use a cannon to shoot the same color circles, you'll have a five minute timer to get rid of them all. There will be three rows of circles, with one of three randomly generated colors (red, blue or green). I got my random color generation working, but since I had it on every circle in the drawfunction the colors were changing everytime the screen refreshed. So I need to put the random color generation in my main function and use an array to point at my drawCircle function. However I thought it might be easier if I drew my circles with a for loop. It's 15 circles per row and I had been planning on doing three loops so I only had to worry about the x component.
What I was trying to do with that piece of code was to draw my 15 cicles, keep the y component and translate the x component over 28 units for each circle so you have:
OOOOOOOOOOOOOOO
a row of fifteen side by side circles
I'm guessing my attempt was totally off the mark?
|
|
|
|
|
Lose the [20] on the definition of Circle1. You've define it as an array of 20 integers and they try to use it as a single integer. That will get rid of the compiler error, I think, but it's hard to say if it will then do what you want based in so little information.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
That did get rid of the compile error thank you.
However you're correct in thinking it might not do what I want. It was only drawing one circle that can be seen. However, you all's posts made me realize I should be calling the int o I have in the translation. This kinda worked, except it drew them too close together.
My revised portion is:
int o = 54;
for
(o=0; o<15; o++)
{
glPushMatrix();
glTranslatef(o+28,455,1);
random_generator(0,3);
if (randomValue == 0)
{
glColor3f(0,.5,0);
}
else if (randomValue == 1)
{
glColor3f(.5,0,0);
}
else
{
glColor3f(0,0,.5);
}
glLineWidth(1.0);
drawCircle(14,200);
glPopMatrix();
}
This is what it looks like:
http://img.photobucket.com/albums/v222/Carlota/Circles.png
I need to get the circles to be side by side. Though I was under the impression I needed to do this in an array so that later I could set up if then statements to change flags so I could turn the circle off if it was hit by the fired circle?
modified on Wednesday, December 9, 2009 3:39 AM
|
|
|
|
|
Look at your code and then look at the picture.
You're translating the circles in 1 pixel increments (glTranslatef(o+28,455,1); , where o is incremented by 1 each pass through the for loop), and that's exactly what the image shows - the circles are drawn almost on top of one another, with each one 1 pixel further to the right than it's predecessor.
If you want the circles side by side, increase the offset between them.
And storing indices to the circles in an array will probably make processing the circles easier later, but it isn't absolutely necessary. Take it one step at a time - get your circles drawn where you want them first, then try optimizing the code (using an array, for instance) after you've gotten the basics working.
By the way, your code would be more readable, and you'd probably get better responses, if you straightened out the indenting.
|
|
|
|
|
Thank you so much! I have my circles being drawn perfect, here's how I ended up doing this:
void drawCircleRow1()
{
for
(o=0; o<15; o++)
{
random_generator(0,3);
glPushMatrix();
glTranslatef((o+1.9)*28,455,1);
if (randomValue == 0)
{
glColor3f(0,.5,0);
}
else if (randomValue == 1)
{
glColor3f(.5,0,0);
}
else
{
glColor3f(0,0,.5);
}
glLineWidth(1.0);
drawCircle(14,200);
glPopMatrix();
}
}
picture:
http://img.photobucket.com/albums/v222/Carlota/CircleLoop.png
|
|
|
|
|
Chidori-chan wrote: but I've been running into some issues
Which are ?? Without a clear description of the problem, we won't be able to help you at all...
Anyway, if you are interested, you can also look at my sig, there's a link to a series of tutorials about game programming with OpenGL.
|
|
|
|
|
By MSDN, that CDC::LineTo(pt) will draw a line to, but not include the specified "pt".
Why is that? any special purpose?
|
|
|
|
|
Because that is the way Microsoft designed it; maybe you should ask them. In many cases the next drawing command will start from the x,y point of the previous one, so I assume this is for efficiency.
|
|
|
|
|
thanks,
you said ask microsoft. do you mean I should post this to MSDN forum? or just mail to someone?
|
|
|
|
|
fitatc wrote: you said ask microsoft. do you mean I should post this to MSDN forum? or just mail to someone?
Try one of the Microsoft forums. How important is it to you to know?
|
|
|
|
|
Thank you very much.
Richard MacCutchan wrote: Try one of the Microsoft forums. How important is it to you to know?
To my work, not a bit.
To mySelf, I am kind of serious man,
|
|
|
|
|
anybody has clearly defination of De Boor method ??
thank very much !!
|
|
|
|
|
You can check out the book by Carl DeBoor: "A Practical Guide to Splines". The programs in that book are in FORTRAN but can be easily rewritten in C++. I read that book in 1986 and learned a lot. Hope that can help you, too.
|
|
|
|
|
We need more coders/designers on our team to develop an AI like none other. The AI, Codenamed Project Vital, will change the world and could turn over enormous profits, but only if it is successful. We could use any help we can get, from little experience to advanced experience. If this project is a success, and even if it isn't, it will be a great learning experience, as well as something, or something else, to add to your programming profile.
Thank you for considering Project Vital,
Gabe Parmley, CEO of Parmley Interactive
gabeparmley@gmail.com
|
|
|
|
|
Shouldn't this be in the 'Jobs' forum?
|
|
|
|
|
but its not a paying job, atleast not yet, its a C++ project and anyone can help
|
|
|
|
|
Your websites aren't very informative. Just a mass of broken links and dead pages.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
yes, we are working on getting them back online, sorry for the inconvenience.
|
|
|
|
|
This is gonna sound like a really stupid question, but I'm new to C++ (been using C#).
If I have a pointer to a char, how can I display the char in a messagebox? (I know to use MessageBoxA but I'm not sure how to make the char into something the MessageBoxA function accepts)
|
|
|
|
|
Omnicoder wrote: If I have a pointer to a char...
Which looks like:
char c;
char *p = &c; Omnicoder wrote: how can I display the char in a messagebox?
You'll need a pointer to an "array" of characters, like:
char *p = "Hello World";
MessageBox(p); MessageBox() expects a pointer to a null-terminated string which is different than a pointer to a character.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In addition to David's answer, I want to say that you should never call a specific version of a function like MessageBox (so, calling MEssageBoxA or MessageBoxW is wrong). You should always stick to the generic version (without the A or W at the end). Character encoding causes in general a lot of troubles to new programmers, so I strongly suggest this excellent article[^] in order to better understand the concepts. Even if your code compiles now, reading this article can save you a LOT of time for the future (and probably a lot of problems too ).
|
|
|
|
|
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going
|
|
|
|