Mar 14, 2012 at 11:32am UTC
apparently i missed a bracket but i cant find it. been looking for this error for 2 days now i cant for the love of god find where the error is any help on the issue would be appreciated!!
// SDL_App.cpp : Defines the entry point for our Project
//
//#include "stdafx.h"
#include <Windows.h>
#include "GL_Functions.h"
#include "pctimer.h"
#include <string>
#include <cmath>
#include <crtdbg.h>
int main(int argc, char* argv[])
{
//Lets open the window and initialise opengl
InitGL(1024,768);
int ball = LoadTexture ("./images/ball.png");
int leftpaddle_2 = LoadTexture ("./images/paddle_2.png");
int rightpaddle_1 = LoadTexture ("./images/paddle_1.png");
int iBackground = LoadTexture("./images/background.png");
//int ibackground = 2;
//int ibackgroundy = 0;
//int ibackgroundx = 0;
float paddle_width = 5;
float paddle_length = 15;
float ball_width = 2.5;
float ball_length = 5;
float ballx =492;
float bally =384;
float ballxspeed = 4;
float ballyspeed = 2;
float rightpaddle_1x = 980;
float rightpaddle_1y = 30;
float leftpaddle_2x = 30;
float lefpaddle_2y = 350;
float ballrside = ballx + 40;
char iHighscores[7]= {1,2,3,4,5,6,7};
do
{
//Clear the screen, so previous frames don't build up
ClearScreen();
ballx = ballx + ballxspeed;
bally = bally + ballyspeed;
//draws images to screen
DrawLine(512,0,512,768);
DrawSprite(ball, ballx, bally, 40, 40);
DrawSprite(leftpaddle_2, leftpaddle_2x, lefpaddle_2y, 20, 100);
DrawSprite(rightpaddle_1, rightpaddle_1x, rightpaddle_1y, 20, 100);
//DrawSprite(ibackground, ibackgroundx, ibackgroundy, 1024, 768);
// ball speed/control
if (ballx > 984)
{
ballx = 492;
bally = 384;
ballxspeed *= -1;
}
if ( ballx < 0)
{
ballx = 492;
bally = 384;
ballxspeed *= -1;
}
if (bally > 728 || bally < 0)
ballyspeed *= -.5;
// controls for players one and two
// player one's controls ( 'w' and 's')
// player two's controls ( 'up' and 'down')
if (IsKeyDown(KEY_UP))
{
rightpaddle_1y = rightpaddle_1y -5;
if( rightpaddle_1y < 0 )
{
rightpaddle_1y = 0;
}
}
{
if (IsKeyDown(KEY_DOWN) && rightpaddle_1y < 668)
rightpaddle_1y = rightpaddle_1y +5;
if (IsKeyDown('w') && lefpaddle_2y > 0)
lefpaddle_2y = lefpaddle_2y -5;
if (IsKeyDown('s') && lefpaddle_2y < 668)
lefpaddle_2y = lefpaddle_2y +5;
}
//Esc will quit the game.
if (IsKeyDown(KEY_ESCAPE))
return 0;
//limit paddles so that stay with in boundaries placed
{
if (ballx < lefpaddle_2y && ballx > lefpaddle_2y && bally > lefpaddle_2y - 20 && bally < lefpaddle_2y + 120)
ballxspeed *= -1;
if (ballx + 40 > rightpaddle_1x && ballx + 40 < rightpaddle_1x && bally > rightpaddle_1y - 20 && bally < rightpaddle_1y + 120)
ballxspeed *= -1;
if(lefpaddle_2y + paddle_width > 668)
lefpaddle_2y = 668 - paddle_width;
if(rightpaddle_1x + paddle_width > 1023)
rightpaddle_1x = 1023 - paddle_width;
}
if(ball_length + ball_width > paddle_width + paddle_length)
ballx,bally = 0;
{
if(rightpaddle_1x >= ballx && rightpaddle_1x <= (ballx + ball_width) ||
(rightpaddle_1x + paddle_width ) >= ballx && (rightpaddle_1x + paddle_width ) <= (ballx + ball_width))
//The ball and paddle appear to overlap...so it should bounce
if(rightpaddle_1y >= bally && rightpaddle_1y <= ( bally + ball_length) ||
(rightpaddle_1y + paddle_length) >= bally && (rightpaddle_1y + paddle_length) <= ( bally +ball_length))
//Stop it from running too fast! Sleep ZZzzz
Sleep(5);
}
while (FrameworkUpdate()); //Do some secret stuff,
FreeTexture(ball);
FreeTexture(leftpaddle_2);
FreeTexture(rightpaddle_1);
FreeTexture(iBackground);
//Close down
CloseDown();
_CrtDumpMemoryLeaks();
//Quit!
return 0;
}
Mar 14, 2012 at 11:51am UTC
Use code tags: [co de]Your code
[/code] (Left of the edit field you find 'Format:' press the <> button an voila)
After ballx,bally = 0;
you open the curly brace but never close it