-
Notifications
You must be signed in to change notification settings - Fork 0
/
FirstRobot.cpp
71 lines (60 loc) · 1.45 KB
/
FirstRobot.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//FirstRobot.cpp - FirstRobot SubClass Definitions
//Written by Ethan Goff, April 2013
//Uses Dark GDK, http://www.thegamecreators.com/?m=view_product&id=2128
#pragma once
#include "FirstRobot.h"
//Constructors
FirstRobot::FirstRobot() : AICharacter() {}
FirstRobot::FirstRobot(const int spriteID, int x, int y, int initialImageID, Direction initialDirection, const unsigned int velocity) : AICharacter(spriteID, x, y, initialImageID, initialDirection, velocity)
{
FSLFire = 0;
FireDirection = none;
}
//AI Aiming Management Method
void FirstRobot::Aim(Tile& PlayerLocale)
{
FSLFire++;
if(FSLFire > ROBOT_FIRE_PERIOD)
{
FSLFire = 0;
if(PlayerLocale.IndexX == Locale.IndexX)
{
if(PlayerLocale.IndexY < Locale.IndexY)
FireDirection = up;
else
FireDirection = down;
return;
}
else if(PlayerLocale.IndexY == Locale.IndexY)
{
if(PlayerLocale.IndexX > Locale.IndexX)
FireDirection = right;
else
FireDirection = left;
return;
}
}
else
FireDirection = none;
}
//Animation Methods
void FirstRobot::Animate(){}
void FirstRobot::DeathAnimate()
{
FSDeath++;
FSLDeathAnimation++;
if(FSDeath < 3*FRAME_RATE)
{
dbSprite(SpriteID, Position.X, Position.Y, IMG_ROBOT1_DEATH1 + (FSDeath/3));
dbOffsetSprite(SpriteID, 0, DEATH_ANIMATION_OFFSET);
}
else
{
Respawn = true;
}
}
//Access Methods
Direction FirstRobot::GetFireDirection() const
{
return FireDirection;
}