/[anoncvs]/projects/roguelike/View.cpp


UCC Code Repository

Contents of /projects/roguelike/View.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Thu Apr 13 07:11:07 2006 UTC (15 years ago) by banana
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +4 -6 lines
LOS code finished using libfov

1 #include "View.h"
2 #include "core.h"
3 using namespace std;
4
5 raw_screen View::render() {
6 attributed_char *screenp = (attributed_char *)malloc(width * height * sizeof(attributed_char));
7
8 World::location square;
9
10 //Render square-at-a-time
11 for (int x = left; x < width + left; x++) {
12 for (int y = top; y < height + top; y++) {
13 square = myWorld->at(x, y);
14
15 if (square.character && square.los) { //Top layer: Characters
16 *(screenp + y * width + x) = square.character->render();
17 } else if (square.los || square.memory) { //Bottom layer: Terrain
18 *(screenp + y * width + x) = square.terrain->render();
19 } else {
20 (screenp + y * width + x)->character = L' ';
21 }
22 }
23 }
24
25
26 return screenp;
27 }
28
29 void View::move(int x, int y) {
30 left = x;
31 top = y;
32 }
33
34 void View::resize(int x, int y) {
35 width = x;
36 height = y;
37 }
38
39 View::View(World *w) {
40 left = 0;
41 top = 0;
42 width = w->getWidth();
43 height = w->getHeight();
44
45 myWorld = w;
46 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26