# stevo5800

Member

5

182 Neutral

• Rank
Newbie

• Website
1. ## Animation with glut

Use glRotatef to rotate your object. Best way to do this is to move the dot to 0,0, then move the object the same distance, then move it back. For example Let's say the dot was a 10,10 and the object to rotate around the dot was at 10, 20. Then I would move the dot - 10 in the x and - 10 in the y putting it at 0,0. Then You move the objet the same exact distance -10 in the x and - 10 in the y. Then you do you call glRotatef then move the object and dot back the same amount you moved it. That's how it goes in theory. But in OpenGL the matrix are calculated in reverse.   Example  glTranslatef(10.0f ,10.0f ,0.0f); // this gets called third glRotatef(1.0f, 0.0f, 0.0f)// this gets called second glTranslatef(-10.0f ,-10.0f ,0.0f); //this gets called first A bit strange yea but this is how it works, the last movement you make is the first and vis versa. Hope this explains a bit.   Also note if you need the coordinates after a rotate you could do something like this  GLfloat matrix2[16]; glGetFloatv(GL_MODELVIEW_MATRIX, matrix2); double x ,y; //get the x and y from the matrix is self if (matrix2 != NULL) { x = matrix2[12]; y = matrix2[13]; } Also note you can get any value you want from the matrix.     Edited:   The problem with your code is this line static int i = 0; Static means it never changes, and on top of that you declare the int inside the function. So that means each time it calls draw shape() you are setting i = 0; so it never increases. To resolve this make int i = 0 global. Or you could used a glRotatef and not worry about all the extra equations.
2. ## [SOLVED] 'Game' does not compile.

you have 2 definition of the class here's what it should look like    header file      class Game {     // Starts the game     void Start(); };   cpp file   #include "Game.h"   void Game::Start() {     SDL_Init( SDL_INIT_EVERYTHING );     SDL_Quit(); }
3. ## games for phones

HTML5 + javascript build games. The HLTM5 sets up a canvas for display then your game runs in the canvas with javascript.    Coco2x would be a great choice for cross platform since it work on iOS, Android and Windows Phones.    Native language for the phones are    -Android = Java  -Windows Phone = C++ and C# note I'm pretty sure Windows is starting to push more towards Direct X and C++ on the new phones  -iOS = Objective C(not if you really wanted a mac you don't need to buy a top of a line mac to make apps I use a base model that works great)   All the above support C++ as well    Depending on what you want to do and what library you use sometimes you need to use some of the native language.