• Create Account

# stevo5800

Member Since 04 Sep 2012
Offline Last Active Sep 20 2013 03:46 PM

### In Topic: Animation with glut

03 September 2013 - 04:29 AM

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.

### In Topic: [SOLVED] 'Game' does not compile.

03 March 2013 - 07:12 AM

you have 2 definition of the class here's what it should look like

class Game

{

// Starts the game

void Start();

};

cpp file

#include "Game.h"

void Game::Start()

{

SDL_Init( SDL_INIT_EVERYTHING );

SDL_Quit();

}

### In Topic: games for phones

23 January 2013 - 06:20 AM

coco2x it seems like another good solid program. Currently I'm using NetBeans refresh my skills.

I did HTML coding from back in 2001 and never really stayed with the times but HTML5 runs games? Or is this linked with java to create games. I look for tutorials and I see alot of java coding and the only real HTML I see are the basic headers to set up pages and very little code. If I can remember correct you could do this back in the day. Kinda a weird question but what is the major difference?

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.

### In Topic: Can someone link me to some tutorials?

23 January 2013 - 05:50 AM

Animation is as easy as splitting the image into an array. Figure how to split the image and put each part into the same array and Animating is as easy as...

```Image[15];
i++;
if (i > 14)
i = 0;
Draw Image[i];```

BOOM animated. Don't really need a tutorial on animation. Just need to know how to load the image properly. This is just sudo code

EDIT: Not sure if SDL has an easier way of doing it, I know Allegro does but that is irrelevant unless you use Allegro and SDL. As you can use both at the same time.

Animation should be timed with the game loop. If he has nothing slowing down the loop then this will run at different speeds on various machines. But yea it's the basics of it and would give him what he wants for now and good leaning experience. You will want proper timing in your game eventually.

@OP see theres no point in skipping steps to end up with a program that is half functional. If you already know some of the steps then that means you skip tho's tutorials and you do the one's that you don't already know. Programming takes time and patience so if you don't have the patience to do simple tutorials then programming might not be for you. And by the way lazy foo does have animation tutorial witch you could run without doing any other tutorial.

Another thing is you never mentioned what version of SDL you are using, there is 1 official release of SDL 1.2 and the one still in progress SDL 2.0 but stable enough and yes there are differences in them both. SDL 2.0 has a better rendering system then 1.2 and some of the calls are different. So lazyfoo is in 1.2 so if you are running 2.0 a few things will need to be changed.

If you really need a full game example SDL creator also offer source of the game maelstorm found here http://www.libsdl.org/projects/Maelstrom/source.html

I might as well note this also, I'm not sure what skill level your C++ if that's what you are using, but your game should be well object oriented, meaning you will need to know how to properly uses multiple classes and properly structure your game. For example in my game I might have a class that builds a space ship but is bases on my drawing class witch will load the images and draw to the screen. So then anything drawing to the screen will be based of it. So you want animation you will have another class handling your animation and doing the proper loading for your sprite sheet. Obviously people don't use the exact same procedure in setting there class's but the idea is the same. And this is just one of many things that is useful, other things are good to know is link list, vector, deque, virtual functions, pure virtual functions, base class, friends class... and the list goes on.

If your goal is too succeed in this then I would suggest to put a bit more effort and possibly try to make a more simple game at first. If you think it's a waste of time then tell that to the other thousands of programmers who all started with baby steps. First semester at the college we made text base apps in C/C++, then we moves to allegro with is a 2D library then we did SDL. So still in 2D doing some of the same things as before but with a different library. Was it a waste of time? No because I learnt a lot out of it and another thing it teaches you is to adapt to new code/library's.

### In Topic: How does "insalling" a game work?

23 January 2013 - 03:07 AM

+1 for NSIS, I recently got into it with a windows forms app I made. There's a few examples out there that could help you. You can pretty much install files anywhere on the system, create an uninstaller and you specify what you want to remove.

PARTNERS