Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Car.h"
- using namespace std;
- Car::Car(int cx, int cy, SDL_Surface* ccarimage)
- {
- x = cx;
- y = cy;
- carimage = ccarimage;
- }
- void Car::render(SDL_Surface* screenSurface)
- {
- SDL_Rect src, dest;
- //image size
- src.x = 0;
- src.y = 0;
- src.w = carimage->w;
- src.h = carimage->h;
- //image location based on x & y value
- dest.x = 70 + (200 * (x - 1));
- dest.y = 50 + (200 * (y - 1));
- dest.w = carimage->w;
- dest.h = carimage->h;
- //render image
- SDL_BlitSurface(carimage, &src, screenSurface, &dest);
- }
- ostream& operator<<(ostream& os, Car car)
- {
- return cout << "Car at X: " << car.getX() << ", Y: " << car.getY() << "." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement