-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.cpp
90 lines (76 loc) · 1.34 KB
/
Entity.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "Entity.h"
#include "Funzioni.h"
using namespace std;
Entity::Entity(int x, int y, char symbol)
{
defaultX = x;
defaultY = y;
this->x = x;
this->y = y;
this->symbol = symbol;
prevx = -1;
prevy = -1;
}
int Entity::getX()
{
return x;
}
int Entity::getY()
{
return y;
}
void Entity::setX(int x)
{
prevx = this->x;
this->x = x;
}
void Entity::setY(int y)
{
prevy = this->y;
if (y % 2 == 0)
this->y = y;
else
this->y = y - 1;
}
void Entity::increaseX(int x)
{
prevx = this->x;
if (x > 0)
this->x += x;
}
void Entity::increaseY(int y)
{
prevy = this->y;
if (y > 0)
this->y += y;
}
void Entity::decreaseX(int x)
{
prevx = this->x;
if (x > 0)
this->x -= x;
}
void Entity::decreaseY(int y)
{
prevy = this->y;
if (y > 0)
this->y -= y;
}
void Entity::moveTo(int x, int y)
{
prevy = this->y;
prevx = this->x;
this->x = x;
this->y = y;
}
void Entity::print() // Sposta il cursore nel punto preciso in cui bisogna stampare un carattere
{
PrintAt(x+1, y+1, symbol,prevx+1,prevy+1); // Stampa alla cordinata 'X + 1' o 'Y + 1' perchè la riga 0 e la colonna 0 sono usate per stampare i bordi di gioco
}