I'm just starting a remake of the popular mobile game Angry Birds. I hit a small syntax snag when im trying to calculate power of a shot downwards (my game is going to use buoyancy of a penguin rather than gravity).
Somewhere in the either the prototype for the Dist function, the function declaration itself, or in the Refresh_Screen() function is a syntax error preventing the code from running right. it wont build right and if i put in breakpoints they say "this breakpoint won't be hit because the source code is different than the original...."
HELP!
main.cpp:
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "Globals.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void Load_Media();
void Setup_Level(int LevelCode);
void Refresh_Screen();
double Dist(int Xa, int Ya, int Xb, int Yb);
// the main entry point for the application is this function
void DarkGDK ( void )
{
Setup_Level(0);
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetDisplayMode(800,600,32);
// our main loop
while ( LoopGDK ( ) )
{
if(NewLevelFlag==1) {
//If there is an old level BMP in place, delete it
if(dbBitmapExist(1)==1)
dbDeleteBitmap(1);
//Create a new level BMP based off above specs
dbCreateBitmap(1,LevelWidth,LevelWidth*(.75));
dbInk(dbRGB(100,200,255),0);
dbSetCurrentBitmap(1);
dbBox(0,100,LevelWidth,LevelWidth*(.75));
dbSetCurrentBitmap(0);
//Reset the flag
NewLevelFlag=0;
//Make ink color black
dbInk(0,0);
}
Refresh_Screen();
// update the screen
dbSync ( );
}
// return back to windows
return;
}
void Load_Media() {
return;
}
void Setup_Level(int LevelCode) {
switch(LevelCode) {
case 0:
//Sample Level
LevelWidth = 800;
break;
}
NewLevelFlag=1;
return;
}
void Refresh_Screen() {
dbCLS();
dbCopyBitmap(1,0,0,799,599,0,0,0,799,599);
double MouseAngle = atan(<double>(dbMouseY()-100)/(dbMouseX()));
double Power = Dist(0,100,dbMouseX(), dbMouseY());
if(Power>200)
Power=200;
dbBox(0,100,cos(MouseAngle)*Power,sin(MouseAngle)*Power);
return;
}
double Dist(int Xa, int Ya, int Xb, int Yb) {
int D1 = Xa - Xb;
int D2 = Ya - Yb;
int Dsq = (D1^2)+(D2^2);
return (Dsq^(.5));
}
Globals.h:
int LevelWidth;
int NewLevelFlag=0;