Thread Solved

Join Date: Aug 2009
Posts: 12
Reputation: ammadkhan has a little shameless behaviour in the past 
Solved Threads: 0
ammadkhan ammadkhan is offline Offline
Newbie Poster

RAMP GAME

 
0
  #1
Aug 29th, 2009
--------------------------------------------------------------------------------

HELLO FRIENDS...
I M MAKING A GAME WHICH IS CALLED "RAMP GAME".
THIS GAME CONSIST OF
1) A BALL, 2) A BASKET, 3) SOME LINES ( which can be place anywhere by the user with in the boundary walls).

HERE IS TEH LINK....
SNIP
u can see what it looks like....

now what i m here for?....is i dont know how to bounce a ball w.r.t the collision angle..... i don't know how to move lines at run time.....
i should no my problems here, so u can understand what i m trying to say...

1) Setting the lines at run time.
2) When ball collides with the lines then it should reflect w.r.t the angle of
reflection.

ONE MORE THING......there is a restriction that the game should be made on "OPENGL".

PLEASE HELP ME OUT WHO KNOWS OPENGL.......
Last edited by happygeek; Aug 29th, 2009 at 9:11 am. Reason: link snipped
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: RAMP GAME

 
1
  #2
Aug 29th, 2009
Running around YELLING and cross-posting all over the web won't make it happen any quicker.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 12
Reputation: ammadkhan has a little shameless behaviour in the past 
Solved Threads: 0
ammadkhan ammadkhan is offline Offline
Newbie Poster

Re: RAMP GAME

 
0
  #3
Aug 29th, 2009
well is there any rule not to ask our problems here ??????
can any1 help me here then plz tell me.....
my cprogramming thread is closed , i don't know y....
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,176
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 146
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: RAMP GAME

 
0
  #4
Aug 29th, 2009
Ask your question in a clear and concise manner.
I give up! 
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
3) What is the 123456789 prime numer?
Ask4Answer
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 12
Reputation: ammadkhan has a little shameless behaviour in the past 
Solved Threads: 0
ammadkhan ammadkhan is offline Offline
Newbie Poster

Re: RAMP GAME

 
0
  #5
Aug 29th, 2009
ok....
1)i want to set the lines at run time.( w.r.t. x-axis,y-axis,clockwise and anti-clockwise)
2)i want to detect collision of a circle with the lines(which may be in slope), and after collision the circle should bounce in a paricular direction.....
[edit]
using OPENGL
[/edit]
Last edited by ammadkhan; Aug 29th, 2009 at 5:43 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: RAMP GAME

 
0
  #6
Aug 29th, 2009
Rules on where to post
http://www.catb.org/~esr/faqs/smart-...ons.html#forum

Rules on topic titles
http://www.catb.org/~esr/faqs/smart-...tml#bespecific

Rules on language and spelling
http://www.catb.org/~esr/faqs/smart-...html#writewell

And so on...


Edit:
oh, and your cprogramming.com thread has been reopened.
Last edited by Salem; Aug 29th, 2009 at 5:45 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,176
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 146
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: RAMP GAME

 
0
  #7
Aug 29th, 2009
Originally Posted by ammadkhan View Post
ok....

1)i want to set the lines at run time.( w.r.t. x-axis,y-axis,clockwise and anti-clockwise)
Ok whats the problem. In your drawFunc have the (X_i,Y_i,Z_i)
and the (X_f, Y_f, Z_f) as variables and change it accordingly. Maybe
if '+' is pressed, increase the length of each X coord by 1 unit...

Originally Posted by ammadkhan View Post
2)i want to detect collision of a circle with the lines(which may be in slope), and after collision the circle should bounce in a paricular direction.....
Option # 1) Check if the lines is within the circle's position. The
circle position has an X,Y,Z coordinate. If the line is within the area
of the circle then there is a collision. And move the circle -x.

Option # 2) Check if the circle + radius is within the Top height
and the low height of the line. If so then check if its X position + radius
is within the lines X coordinate of the line. If so then there is a collision and
move circle to -x, maybe by making its x velocity = -x velocity.
I give up! 
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
3) What is the 123456789 prime numer?
Ask4Answer
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 12
Reputation: ammadkhan has a little shameless behaviour in the past 
Solved Threads: 0
ammadkhan ammadkhan is offline Offline
Newbie Poster

Re: RAMP GAME

 
0
  #8
Aug 30th, 2009
Can i change the line positions by not making any function of darwline()????
I m using opengl in which i can use
GLBegin(gl_lines);
And i m working in 2D.....
And can u plz help me in coding manners??? or pseudo code????
if it doesn't matter to u......?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 12
Reputation: ammadkhan has a little shameless behaviour in the past 
Solved Threads: 0
ammadkhan ammadkhan is offline Offline
Newbie Poster

Re: RAMP GAME

 
0
  #9
Aug 30th, 2009
I have this Piece of code to bounce a ball.....
#include <gl/glut.h>  // Also included gl.h, glu.h
#include <Math.h>     // Needed for sin, cos
#define PI 3.14159265f
      
// Global variables
char title[] = "Bouncing Ball (2D)";  // Windowed mode's title
int windowWidth  = 640;     // Windowed mode's width
int windowHeight = 480;     // Windowed mode's height
int windowPosX   = 50;      // Windowed mode's top-left corner x
int windowPosY   = 50;      // Windowed mode's top-left corner y
   
GLfloat ballRadius = 0.5f;   // Radius of the bouncing ball
GLfloat xPos = 0.0f;         // Ball's (x, y) position
GLfloat yPos = 0.0f;
GLfloat xPosMax, xPosMin, yPosMax, yPosMin; // Ball's (x, y) bounds
GLdouble xLeft, xRight, yBottom, yTop;      // Projection clipping area
GLfloat xSpeed = 0.02f;      // Ball's speed in x and y directions
GLfloat ySpeed = 0.007f;
int refreshMillis = 30;      // Refresh period in milliseconds
      
// Initialize OpenGL Graphics
void initGL() {
   glClearColor(0.0, 0.0, 0.0, 1.0); // Set background (clear) color to black
}
   
// Callback handler for window re-paint event
void display() {
   glClear(GL_COLOR_BUFFER_BIT);    // Clear the color buffer
   
   glLoadIdentity();                // Reset model-view matrix
   glTranslatef(xPos, yPos, 0.0f);  // Translate to (xPos, yPos)
   // Use triangular segments to form a circle
   glBegin(GL_TRIANGLE_FAN);
      glColor3f(0.0f, 0.0f, 1.0f);  // Blue
      glVertex2f(0.0f, 0.0f);       // Center of circle
      int numSegments = 100;
      GLfloat angle;
      for (int i = 0; i < numSegments; i++) {
         angle = i * 2.0f * PI / numSegments;  // 360 deg for all segments
         glVertex2f(cos(angle) * ballRadius, sin(angle) * ballRadius);
      }
      glVertex2f(ballRadius, 0.0f);     // Last vertex
   glEnd();
   
   glutSwapBuffers();  // Swap front and back buffers (of double buffered mode)
   
   // Animation Control - compute the location for the next refresh
   xPos += xSpeed;
   yPos += ySpeed;
   // Check if the ball exceeds the edges
   if (xPos > xPosMax) {
      xPos = xPosMax;
      xSpeed = -xSpeed;
   } else if (xPos < xPosMin) {
      xPos = xPosMin;
      xSpeed = -xSpeed;
   }
   if (yPos > yPosMax) {
      yPos = yPosMax;
      ySpeed = -ySpeed;
   } else if (yPos < yPosMin) {
      yPos = yPosMin;
      ySpeed = -ySpeed;
   }
}
   
// Call back when the windows is re-sized.
void reshape(GLsizei weight, GLsizei height) {
   if (height == 0) height = 1;               // To prevent divide by 0
   GLfloat aspect = (GLfloat)weight / height; // Get aspect ratio
   
   // Set the viewport to cover the entire window
   glViewport(0, 0, weight, height);
   
   // Adjust the aspect ratio of clipping area to match the viewport
   glMatrixMode(GL_PROJECTION); // Select the Projection matrix
   glLoadIdentity();            // Reset
   if (weight <= height) {
      xLeft   = -1.0;
      xRight  = 1.0;
      yBottom = -1.0 / aspect;
      yTop    = 1.0 / aspect;
   } else {
      xLeft   = -1.0 * aspect;
      xRight  = 1.0 * aspect;
      yBottom = -1.0;
      yTop    = 1.0;
   }
   gluOrtho2D(xLeft, xRight, yBottom, yTop);
   xPosMin = xLeft + ballRadius;
   xPosMax = xRight - ballRadius;
   yPosMin = yBottom + ballRadius;
   yPosMax = yTop - ballRadius;
   
   // Reset the model-view matrix
   glMatrixMode(GL_MODELVIEW); // Select the model-view matrix
   glLoadIdentity();           // Reset
}
   
// Animation timer function
void Timer(int value) {
	glutPostRedisplay();    // Post a paint request to activate display()
	glutTimerFunc(refreshMillis, Timer, 0); // subsequent timer call at milliseconds
}
   
// main function - GLUT run as a Console Application
int main(int argc, char** argv) {
   glutInit(&argc, argv);            // Initialize GLUT
   glutInitDisplayMode(GLUT_DOUBLE); // Enable double buffered mode
   glutInitWindowSize(windowWidth, windowHeight);  // Initial window width and height
   glutInitWindowPosition(windowPosX, windowPosY); // Initial window top-left corner (x, y)
   glutCreateWindow(title);      // Create window with given title
   glutDisplayFunc(display);     // Register callback handler for window re-paint
   glutReshapeFunc(reshape);     // Register callback handler for window re-shape
   glutTimerFunc(0, Timer, 0);   // First timer call immediately
   initGL();                     // Our own OpenGL initialization
   glutMainLoop();               // Enter event-processing loop
   return 0;
}
Can u explain me what Timer() and reshape() do here inthis piece of code?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,413
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 114
Sponsor
William Hemsworth William Hemsworth is online now Online
Nearly a Posting Virtuoso

Re: RAMP GAME

 
0
  #10
Aug 30th, 2009
Okay, you clearly didn't write that code, so before you go any further, do you actually understand any of this or have a knowledge of OpenGL at all? if not, read a book or tutorial first then give it a shot.

i want to detect collision of a circle with the lines(which may be in slope), and after collision the circle should bounce in a paricular direction.....
If you want to bounce off an angled surface, your problem requires some physics, so unless you really know your stuff, don't consider this an easily achievable task.
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Game Development Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC