i just started to make my first opengl game (im using glut), just a simple scrolling space shooter like r-type. right now its not near complete but the basics are all their and i should be able to move around the level. there arent any textures yet, or even enemies ( ive been having huge problems trying to load textures sence im on a mac ). but the basics of the engine should run im pretty sure its all right and makes sence. i cant get it to compile, xcode keeps on bringing up the stupid debugger and i dont know why but i know it means somethings not right. and i cant get it to compile with gcc because i dont know how to link frameworks in unix. the game doesnt have collision detection yet, so you cant die, i just wanted to make sure everything works first before i continue and finish the game. theres no commenting or anything but the codes pretty simple and straight forward. if someone would help me out thatd be really cool cause my teacher doesnt actually know how to program, im taking an independent study so im stuck with the it guy who thinks he knows everything about computers but doesnt know anything.

the game is pretty simple, the player moves around the screen and the level moves backwards under the screen to simulate movement.

main.cpp -

Code:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>

#include "globals.h"
#include "timer.h"
#include "init.h"

#define winWidth 640
#define winHeight 480

void game_Loop( void );

int main( int argc, char **argv )
{
	init_GL();
	init_Game();
	
	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
	glutInitWindowPosition( 300, 250 );
	glutInitWindowSize( winWidth, winHeight );
	glutCreateWindow( " " );
	
	glutDisplayFunc( draw_Screen );
	game_Loop();
	
	return 0;
}

void game_Loop( void )
{
	while( GAME_STATUS = ALIVE )
	{
		glutTimerFunc( 1000/60, timer, 1 );
	}
}
globals.h -

Code:
enum status { ALIVE, DEAD };

status GAME_STATUS;

struct properties
{
	float xPosition;
	float yPosition;
	float xSpeed;
	float ySpeed;
};

properties player;
	
float levelScroll;

int totalTime;
timer.h -
not to much to explain about the timer, the int totalTime here doesnt do anything right now but eventually i was going to use it to have a scoring system. w a s d to move, and the level scrolls backwards 0.1 every frame to simulate movement, because i couldnt figure out how i could actualy have constant movement but still be able to move freely around the screen.

Code:
#include "collisions.h"
#include "render.h"

void check_Keys( unsigned char key, int x, int y )
{
	switch( key )
	{
		case 'a':
			player.xSpeed -= 0.1;
		case 'd':
			player.xSpeed += 0.1;
		case 's':
			player.ySpeed -= 0.1;
		case 'w':
			player.ySpeed += 0.1;
		default:
			break;
	}
}

void update_Positions( void )
{
	player.xSpeed = 0.0;
	player.ySpeed = 0.0;

	glutKeyboardFunc( check_Keys );
	
	player.xPosition += player.xSpeed;
	player.yPosition += player.ySpeed;
	
	levelScroll -= 0.1;
}

void update_Status ( void )
{
	if( collision_Player() == 1)
		GAME_STATUS = DEAD;
	else
		GAME_STATUS = ALIVE;
}

void timer( int time )
{
	update_Positions();
	update_Status();
	
	if( GAME_STATUS == ALIVE )
	{
		glutDisplayFunc( draw_Screen );
		totalTime += time;
		glutTimerFunc( 1000/60, timer, 1 );
	}
}
render.h -
i made the level faded in color from end to end just so you can see that its actually moving, once i can get textures figured out ill put one on and itll look alot nicer. eventually ill make the player not just and triangle and put textures on that too.

im not sure if the way i even made the level and player move would really work, just using translate like that but it seems like it makes sence, but at the same time it seems too simple for it to actually work.

Code:
void draw_Level( void )
{
	glPushMatrix();
	glTranslatef( 0.0f, levelScroll, 0.0f );
	glBegin( GL_QUADS );
	
		glColor3f( 1.5f, 0.0f, -0.5f );
		glVertex3f( -1.5f, -1.5f, -0.5f );
		glVertex3f( 1.5f, -1.5f, -0.5f );
		glColor3f( 0.0f, 1.5f, -0.5f );
		glVertex3f( -1.5f, 5.5f, -0.5f );
		glVertex3f( 1.5f, 5.5f, -0.5f );
	
	glEnd();
	glPopMatrix();
}

void draw_Player( void )
{
	glPushMatrix();
	glTranslatef( player.xPosition, player.yPosition, 0.0f );
	glBegin( GL_TRIANGLES );
	
		glColor3f( 1.0f, 1.0f, 1.0f );
		glVertex3f( -0.1f, -0.1f, 0.0f );
		glVertex3f( 0.1f, -0.1f, 0.0f );
		glVertex3f( 0.0f, 0.1f, 0.0f );
		
	glEnd();
	glPopMatrix();
}

void draw_Screen( void )
{
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glLoadIdentity();
	
	draw_Level();
	draw_Player();
	
	glLoadIdentity();
	glutSwapBuffers();
}
collisions.h -
im not really too worried about collisions yet, eventually id like to just have a mask under the level and compare it to the player, but for now i just want to get moving around on the screen.

Code:
bool collision_Player( void )
{
	return 0;
}
init.h

Code:
void init_GL( void )
{
	glShadeModel( GL_SMOOTH );
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	glClearDepth( 1.0f );
	glEnable( GL_DEPTH_TEST );
	glDepthFunc( GL_LEQUAL );
	glHint( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST );
}

void init_Game( void )
{
	player.xPosition = 0.0f;
	player.yPosition = -0.75f;
	player.xSpeed = 0.0;
	player.ySpeed = 0.0;
	
	GAME_STATUS = ALIVE;
	
	levelScroll = 0.0f;
}