-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.cpp
More file actions
119 lines (103 loc) · 3.28 KB
/
Copy pathUnit1.cpp
File metadata and controls
119 lines (103 loc) · 3.28 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "SMemoria.h"
#include "Matrices/SMmatrizCF.h"
#include "Matrices/PmatrizCF.h"
#include "Pilas/Ppila.h"
#include "juego.h"
#include <fstream>
#include <string>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
fstream *f;
Ppila pil;
SMemoria mem;
SMmatrizCF mat(mem);
Juego juego(mat);
int mem_max = 2000;
void print() {
}
void __fastcall TForm1::FormKeyPress(TObject *Sender, System::WideChar &Key)
{
if (true) {
switch (Key) {
case "w"[0]: juego.mv_u(Form1->Canvas); break;
case "a"[0]: juego.mv_l(Form1->Canvas); break;
case "s"[0]: juego.mv_d(Form1->Canvas); break;
case "d"[0]: juego.mv_r(Form1->Canvas); break;
}
juego.draw_map(Form1->Canvas);
}
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
mem.crear();
mat.crear();
mat.definir_valor_repetido("f"[0]);
pil.crear();
randomize();
juego.load_map(StrToInt(Form1->lvl_chooser->Text));
Form1->Repaint();
}
void __fastcall TForm1::FormPaint(TObject *Sender)
{
juego.draw_map(Form1->Canvas);
}
void __fastcall TForm1::btn_rClick(TObject *Sender)
{
juego.mv_r(Form1->Canvas);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn_lClick(TObject *Sender)
{
juego.mv_l(Form1->Canvas);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn_uClick(TObject *Sender)
{
juego.mv_u(Form1->Canvas);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn_dClick(TObject *Sender)
{
juego.mv_d(Form1->Canvas);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::load_lvlClick(TObject *Sender)
{
juego.load_map(StrToInt(Form1->lvl_chooser->Text));
Form1->Repaint();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::show_memoryClick(TObject *Sender)
{
int low_lim = StrToInt(Form1->low_lim->Text);
int hi_lim = StrToInt(Form1->hi_lim->Text) + 1;
int i;
AnsiString str = mem.mostrar().c_str();
Form1->Canvas->Font->Name = "Consolas";
for (i = 0; i < 50; i++) {
Form1->Canvas->TextOut(1050, 10+(15*i), " ");
}
Form1->Canvas->TextOut(1050, 10, "+-----+-+-------------+-------------+-----+");
Form1->Canvas->TextOut(1050, 25, str.SubString(0,43));
Form1->Canvas->TextOut(1050, 40, str.SubString(44,43));
for (i = 0; i < hi_lim - low_lim; i++) {
Form1->Canvas->TextOut(1050, 55+(15*i), str.SubString((low_lim+i)*43+87,43));
if (i == 39 || i == mem_max+1 - low_lim) {break;}
}
Form1->Canvas->TextOut(1050, 55+(15*i), str.SubString((mem_max+3)*43+1,43));
Form1->Canvas->TextOut(1050, 55+(15*(i+1)), str.SubString((mem_max+4)*43+1,43));
Form1->Canvas->TextOut(1050, 55+(15*(i+2)), "Nodo Bicho: " + str.SubString(str.AnsiPos("|O| 98") - 91, 5));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rewindClick(TObject *Sender)
{
juego.retroceder(Form1->Canvas);
}
//---------------------------------------------------------------------------