Click here to Skip to main content
15,898,134 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Create Oracle database(tables) programmatically in VC++ Pin
diptipanchal16-Dec-09 17:04
diptipanchal16-Dec-09 17:04 
GeneralRe: Create Oracle database(tables) programmatically in VC++ Pin
David Crow17-Dec-09 3:12
David Crow17-Dec-09 3:12 
GeneralRe: Create Oracle database(tables) programmatically in VC++ Pin
diptipanchal17-Dec-09 21:48
diptipanchal17-Dec-09 21:48 
QuestionRegarding Mouse Scroll Pin
Paulraj G9-Dec-09 17:04
Paulraj G9-Dec-09 17:04 
AnswerRe: Regarding Mouse Scroll Pin
«_Superman_»9-Dec-09 18:27
professional«_Superman_»9-Dec-09 18:27 
GeneralRe: Regarding Mouse Scroll Pin
Paulraj G9-Dec-09 18:49
Paulraj G9-Dec-09 18:49 
GeneralRe: Regarding Mouse Scroll Pin
«_Superman_»9-Dec-09 18:52
professional«_Superman_»9-Dec-09 18:52 
Questionfalling ball loop Pin
rheeny9-Dec-09 16:23
rheeny9-Dec-09 16:23 
I'm trying to make a game where the user is having to dodge these falling circles the entire time. I figured out how to make the ball fall the first time, but how do i make it fall over and over? I don't want to have to add a bunch of drawcircle functions just so it draws enough before the timer is over - i just want the ball to start back at the top once it falls below the ground.
I know it should be some kind of if statement of forloop or something, but that's as far as I've gotten :/
HELP!




#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

#define WIDTH 600
#define HEIGHT 600

float cx = 0.0;
float cy = 0.0;

int y = 0;
int ball = 0.0;

int min = -100;
int max = 100;


void drawCircles(int x, int y)
{
int i;
int segments = 100;
float radius = 40;


glBegin(GL_POLYGON);
for(i = 0; i < segments; i++)
{
float x = radius * cos(i*2.0*M_PI/segments);
float y = radius * sin(i*2.0*M_PI/segments);
glVertex2f(x,y);
}

glEnd();
}






void drawUser(int x, int y)
{
int i;
int segments = 4;
float radius = 40;


glBegin(GL_POLYGON);
for(i = 0; i < segments; i++)
{
float x = radius * cos(i*2.0*M_PI/segments);
float y = radius * sin(i*2.0*M_PI/segments);
glVertex2f(x,y);
}

glEnd();
}








void displayFunction(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,0,0);

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(10, 300 + ball,0);
drawCircles(10,0);
glPopMatrix();

glPushMatrix();
glTranslatef(cx,cy,0);
glScalef(.3,.3,0);
glRotatef(45,0,0,1);
glColor3f(1,0,0);
drawUser(0,0);
glPopMatrix();

glFlush();
glutSwapBuffers();
}








void timerfunction(int value)
{
ball -= 5;

if(y = 0) y = 300;
glutPostRedisplay();
glutTimerFunc(50,timerfunction,10);

}







void passiveMotionFunction(int x, int y)
{
cx = x - WIDTH/2;
cy = HEIGHT/2 - y;
glutPostRedisplay();
}








int main(int argc, char* argv[])
{
glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(WIDTH, HEIGHT);
glutCreateWindow("SURVIVAL");

glutDisplayFunc(displayFunction);

glutTimerFunc(50,timerfunction,0);

glutPassiveMotionFunc(passiveMotionFunction);

gluOrtho2D(-WIDTH/2, WIDTH/2, -HEIGHT/2, HEIGHT/2);

glClearColor(1,1,1,0);

glutMainLoop();
return 0;
}
AnswerRe: falling ball loop Pin
LunaticFringe9-Dec-09 19:03
LunaticFringe9-Dec-09 19:03 
AnswerRe: falling ball loop Pin
rheeny10-Dec-09 13:30
rheeny10-Dec-09 13:30 
Questioncan use GLUT to read an picture (bmp)??? Pin
a04.lqd9-Dec-09 15:05
a04.lqd9-Dec-09 15:05 
AnswerRe: can use GLUT to read an picture (bmp)??? Pin
Cedric Moonen9-Dec-09 20:26
Cedric Moonen9-Dec-09 20:26 
Questionvoip Pin
geniuspc9-Dec-09 12:38
geniuspc9-Dec-09 12:38 
AnswerRe: voip Pin
Moak10-Dec-09 5:32
Moak10-Dec-09 5:32 
QuestionStack Overflow / Windows CE Newbie Pin
egerving9-Dec-09 12:01
egerving9-Dec-09 12:01 
AnswerRe: Stack Overflow / Windows CE Newbie Pin
Luc Pattyn9-Dec-09 12:36
sitebuilderLuc Pattyn9-Dec-09 12:36 
GeneralRe: Stack Overflow / Windows CE Newbie Pin
egerving10-Dec-09 7:31
egerving10-Dec-09 7:31 
QuestionHow do you merge multiple bitmap files? Pin
Dale Haessel9-Dec-09 10:30
Dale Haessel9-Dec-09 10:30 
AnswerRe: How do you merge multiple bitmap files? Pin
loyal ginger9-Dec-09 10:34
loyal ginger9-Dec-09 10:34 
GeneralRe: How do you merge multiple bitmap files? Pin
Dale Haessel9-Dec-09 17:04
Dale Haessel9-Dec-09 17:04 
GeneralRe: How do you merge multiple bitmap files? Pin
loyal ginger9-Dec-09 17:53
loyal ginger9-Dec-09 17:53 
GeneralRe: How do you merge multiple bitmap files? Pin
LunaticFringe9-Dec-09 19:22
LunaticFringe9-Dec-09 19:22 
AnswerRe: How do you merge multiple bitmap files? Pin
Sauce!9-Dec-09 13:50
Sauce!9-Dec-09 13:50 
AnswerRe: How do you merge multiple bitmap files? Pin
KarstenK9-Dec-09 21:55
mveKarstenK9-Dec-09 21:55 
QuestionCMenu what the scrolling menu buttons named ? Pin
Maximilien9-Dec-09 9:52
Maximilien9-Dec-09 9:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.