-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBall.cpp
More file actions
42 lines (35 loc) · 1.11 KB
/
Ball.cpp
File metadata and controls
42 lines (35 loc) · 1.11 KB
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
37
38
39
40
41
42
// game engine includes
#include "LogManager.h"
#include "GraphicsManager.h"
#include "WorldManager.h"
#include "EventStep.h"
#include "EventOut.h"
// testing includes
#include "Ball.h"
// default constructor
Ball::Ball(){
setType("Ball");
}
// overloaded constructor to take in initial velocity and position
Ball::Ball(float xVelocity, float yVelocity, df::Position pos){
setType("Ball");
setXVelocity(xVelocity);
setYVelocity(yVelocity);
setSolidness(df::HARD);
setPosition(pos);
}
// how to draw the ball on the screen
void Ball::draw(){
df::GraphicsManager::getInstance().drawString(getPosition(), " _ ", df::Justification::LEFT_JUSTIFIED, df::Color::YELLOW);
df::GraphicsManager::getInstance().drawString(df::Position(getPosition().getX(), getPosition().getY()+1), "(_)", df::Justification::LEFT_JUSTIFIED, df::Color::YELLOW);
}
// Handle event (default is to ignore everything).
// Return 0 if ignored, else 1 if handled.
int Ball::eventHandler(df::Event *p_e){
// if out then mark for delete
if (p_e->getType() == DF_OUT_EVENT){
df::WorldManager::getInstance().markForDelete(this);
return 1;
}
return 0;
}