Advertisement
Guest User

Untitled

a guest
Dec 27th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include "Car.h"
  3.  
  4. using namespace std;
  5.  
  6. Car::Car(int cx, int cy, SDL_Surface* ccarimage)
  7. {
  8.     x = cx;
  9.     y = cy;
  10.     carimage = ccarimage;
  11. }
  12.  
  13. void Car::render(SDL_Surface* screenSurface)
  14. {
  15.     SDL_Rect src, dest;
  16.  
  17.     //image size
  18.     src.x = 0;
  19.     src.y = 0;
  20.     src.w = carimage->w;
  21.     src.h = carimage->h;
  22.  
  23.     //image location based on x & y value
  24.     dest.x = 70 + (200 * (x - 1));
  25.     dest.y = 50 + (200 * (y - 1));
  26.     dest.w = carimage->w;
  27.     dest.h = carimage->h;
  28.  
  29.     //render image
  30.     SDL_BlitSurface(carimage, &src, screenSurface, &dest);
  31. }
  32.  
  33. ostream& operator<<(ostream& os, Car car)
  34. {
  35.     return cout << "Car at X: " << car.getX() << ", Y: " << car.getY() << "." << endl;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement