Hi everybody, recently I've been working on getting a simple gravity program where a spaceship orbits around a sun going, I've almost completed it but I've hit a roadblock.
Whenever I compile it says
13 C:\Dev-Cpp\Mission Space rev2\C-SpaceShip.cpp expected `;' before '(' token
and that
29 C:\Dev-Cpp\Mission Space rev2\Body.cpp 'class SpaceShip' has no member named 'Update'
I know it something very simple that's wrong with the function Update in my class, can anyone help me figure it out?
Code:#include "math.h" class SpaceShip { public: long int mass; int locX; int locY; int imageheight; int imagewidth; long int velocityX; long int velocityY; SDL_Rect dest, source; int Update (Planet *pEarth, SDL_Surface *Red, SDL_Surface *screen) { int distance; int forceX; int forceY; long int masses; long int GravVector; long int accelX; long int accelY; distance = sqrt(((*pEarth.dest.x - locX * *pEarth.dest.x - locX) + (*pEarth.dest.y - locY * *pEarth.dest.y - locY))); // this is the distance formula forceX = distance * distance;//these lines are used to square distance distance = forceX;//this is also forceX = 0;//this is the last one masses = (*pEarth.mass * mass); GravVector = masses/distance;//distance is already squared here forceX = GravVector/(*pEarth.dest.x - locX);//normalizes vector into x and y forces instead of vector force, GravVector is a force. forceY = GravVector/(*pEarth.dest.y - locY); accelX = forceX/mass; accelY = forceY/mass; velocityX = velocityX + accelX;//velocity is part of class data not definded in this function velocityY = velocityY + accelY; dest.x = dest.x + velocityX; dest.y = dest.y + velocityY; BlitSurface(Red,source,screen,dest); SDL_UpdateRect(dest.x,dest.y,dest.w,dest.h); return 0; }; SpaceShip(int parmass, int locationX, int locationY, int parimageW, int parimageH ) { velocityX = 0; velocityY = 0; mass = parmass; locY = locationY; locX = locationX; imageheight = parimageH; imagewidth = parimageW; dest.x = locX; dest.y = locY; dest.h = imageheight; dest.w = imagewidth; source.x = 0; source.y = 0; source.h = imageheight; source.w = imagewidth; return; } };//end of class



LinkBack URL
About LinkBacks



