Skip to main content
deleted 23 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276
PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeed*cos(ShipFacing);  //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed*sin(ShipFacing);  //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

YouYou also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}


PBullet.apply_surfacing(PlayerBullet, screen,NULL ); //display bullet while firing

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
    SDL_Rect sourceImage;
    sourceImage.x = ShipSpritesheetX; //position in image file left to right
    sourceImage.y = ShipSpritesheetY; //position in image file up and down
    sourceImage.w = LImageHeight; //width of sprite in image
    sourceImage.h = LImageLength; //height of sprite in image
    SDL_Rect offset; //Holds offsets
    offset.x = XPos;  //Get offsets
    offset.y = YPos;
    SDL_BlitSurface( source, &sourceImage, destination, &offset );  //Blit
}

 PBullet.apply_surfacing(PlayerBullet, screen,NULL ); //display bullet while firing

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}


PBullet.apply_surfacing(PlayerBullet, screen,NULL ); //display bullet while firing

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeed*cos(ShipFacing);  //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed*sin(ShipFacing);  //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
    SDL_Rect sourceImage;
    sourceImage.x = ShipSpritesheetX; //position in image file left to right
    sourceImage.y = ShipSpritesheetY; //position in image file up and down
    sourceImage.w = LImageHeight; //width of sprite in image
    sourceImage.h = LImageLength; //height of sprite in image
    SDL_Rect offset; //Holds offsets
    offset.x = XPos;  //Get offsets
    offset.y = YPos;
    SDL_BlitSurface( source, &sourceImage, destination, &offset );  //Blit
}

 PBullet.apply_surfacing(PlayerBullet, screen,NULL ); //display bullet while firing
added 29 characters in body
Source Link

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

Pbullet & also Enterprise are from class GameObject example

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}


PBullet.apply_surfacing(PlayerBullet, screen,NULL ); //display bullet while firing

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

Pbullet & also Enterprise are from class GameObject example

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}


PBullet.apply_surfacing(PlayerBullet, screen,NULL ); //display bullet while firing

edited body
Source Link

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

Pbullet & also enterpriseEnterprise are from class gameobjectGameObject example

Class gameobject
Private:
public:
double Ypos;
bla bla bla

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

Pbullet & also enterprise are from class gameobject example

Class gameobject
Private:
public:
double Ypos;
bla bla bla

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}

PBullet.XPos=XPos+Enterprise.LImageLength/2; //get bullet YX start ship location
PBullet.YPos=YPos+Enterprise.LImageHeight/2; //get bullet YX start ship location
PBullet.XVel= PBullet.ShipSpeedcos(ShipFacing); //work out angle of bullet
PBullet.YVel= PBullet.ShipSpeed
sin(ShipFacing); //work out angle of bullet
PBullet.TimeOfEvent= SDL_GetTicks(); //start timer for duration of bullet alive

Pbullet & also Enterprise are from class GameObject example

You also need somthing like

GameObject ::apply_surface(SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip)
{
SDL_Rect sourceImage;
sourceImage.x = ShipSpritesheetX; //position in image file left to right
sourceImage.y = ShipSpritesheetY; //position in image file up and down
sourceImage.w = LImageHeight; //width of sprite in image
sourceImage.h = LImageLength; //height of sprite in image
SDL_Rect offset; //Holds offsets
offset.x = XPos; //Get offsets
offset.y = YPos;
SDL_BlitSurface( source, &sourceImage, destination, &offset ); //Blit
}

Source Link
Loading