-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortal.cpp
More file actions
87 lines (66 loc) · 1.76 KB
/
Copy pathPortal.cpp
File metadata and controls
87 lines (66 loc) · 1.76 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
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
#include "Portal.h"
#include "Platform.h"
#include <iostream>
#include <Windows.h>
#include <mmsystem.h>
#include <vector>
#include <string>
#include "SDL_image.h"
#include <conio.h>
#include <thread>
#include <chrono>
#include "Portal_Rosu.h"
#include "SDL.h"
#include "Menu.h"
#include "Global.h"
#undef main
#pragma comment(lib, "winmm.lib")
#include "Player.h"
int Portal::width = 30;
int Portal::height = 40;
float Portal::pozx = -30;
float Portal::pozy = -30;
float Portal::centru_x;
float Portal::centru_y;
float Portal::colt_dr_jos_x = pozx + width;
float Portal::colt_dr_jos_y = pozy + height;
void Portal::setRender(SDL_Renderer* renderer)
{
ren = renderer;
}
void Portal::portal_apar()
{
SDL_Rect rct;
rct.x = pozx;
rct.y = pozy;
rct.w = width;
rct.h = height;
SDL_Texture* po = IMG_LoadTexture(ren, "Imagini/Portal1.bmp");
SDL_RenderCopy(ren, po, NULL, &rct);
SDL_DestroyTexture(po);
centru_x = pozx + width / 2.0f;
centru_y = pozy + height / 2.0f;
}
int teleportCooldown = 0;
void Portal::check() {
float tolerance = 50;
if (teleportCooldown > 0) {
teleportCooldown -= 1;
return;
}
if (abs(Player::centru_x - centru_x) <= tolerance &&
abs(Player::centru_y - centru_y) <= tolerance &&
Player::ok_tp == 1 && Player::ok_tp_rosu == 1)
{
Player::ok_tp_rosu = 0;
Player::ok_tp = 0;
Player::pozy = Portal_Rosu::pozy;
Player::pozx = Portal_Rosu::pozx;
teleportCooldown = 100;
}
if ((abs(Player::centru_x - centru_x) > tolerance ||
abs(Player::centru_y - centru_y) > tolerance))
{
Player::ok_tp = 1;
}
}