-
Notifications
You must be signed in to change notification settings - Fork 0
/
Car.cpp
36 lines (27 loc) · 710 Bytes
/
Car.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "Car.h"
#include <iostream>
Car::Car()
{
xdir = -2;//how far it moves for each time out
ydir = 0;
image.load(":/icons/images/Car.jpg");//loads image from file.
rect = image.rect();
rect.setWidth(60);//sets the dimensions of the car
rect.setHeight(40);
}
Car::Car(int xSpeed, int ySpeed):Vehicle(xSpeed,ySpeed){
image.load(":/icons/images/Car.jpg");//loads image from file.
rect = image.rect();
rect.setWidth(60);//sets the dimensions of the car
rect.setHeight(40);
}
Car::~Car() {//destructor.
}
void Car::autoMove()//moves to the left
{
//for (int i=1; i<=xdir; i++)
rect.translate(xdir, ydir);
if (rect.right() <= 0) {
rect.translate(460,ydir);
}
}