Added map scrolling and camera...
This commit is contained in:
parent
160792ed8c
commit
bc403da11b
@ -1,5 +1,8 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
|
int camera_x = 30;
|
||||||
|
int camera_y = 30;
|
||||||
|
|
||||||
void view_unit (int race, int unit, int x, int y) {
|
void view_unit (int race, int unit, int x, int y) {
|
||||||
int u, v, width, height;
|
int u, v, width, height;
|
||||||
|
|
||||||
@ -100,14 +103,13 @@ void view_neon_menu (int menu, int align, int x, int y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_map (void) {
|
void view_map (int offset_x, int offset_y) {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
for (x = 0; x < CHAD_WORLD_WIDTH; ++x) {
|
for (x = 0; x < (render_width () - SIDE_SIZE) / (BASE_SIZE * render_zoom); ++x) {
|
||||||
if (x * BASE_SIZE * render_zoom > render_width () - SIDE_SIZE) break;
|
for (y = 0; y < render_height () / (BASE_SIZE * render_zoom); ++y) {
|
||||||
|
render_sprite (ashlands, (int) (x * BASE_SIZE * render_zoom), (int) (y * BASE_SIZE * render_zoom), 0,
|
||||||
for (y = 0; y < CHAD_WORLD_HEIGHT; ++y) {
|
chad_world [0] [offset_x + x] [offset_y + y] * BASE_SIZE, BASE_SIZE, BASE_SIZE);
|
||||||
render_sprite (ashlands, (int) (x * BASE_SIZE * render_zoom), (int) (y * BASE_SIZE * render_zoom), 0, chad_world [0] [x] [y] * BASE_SIZE, BASE_SIZE, BASE_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
extern int camera_x;
|
||||||
|
extern int camera_y;
|
||||||
|
|
||||||
extern void view_unit (int race, int unit, int x, int y);
|
extern void view_unit (int race, int unit, int x, int y);
|
||||||
|
|
||||||
extern void view_menu (int menu, int align, int x, int y);
|
extern void view_menu (int menu, int align, int x, int y);
|
||||||
@ -15,7 +18,7 @@ extern void view_hud (int alpha, int width, int height, int x, int y);
|
|||||||
|
|
||||||
extern void view_neon_menu (int menu, int align, int x, int y);
|
extern void view_neon_menu (int menu, int align, int x, int y);
|
||||||
|
|
||||||
extern void view_map (void);
|
extern void view_map (int offset_x, int offset_y);
|
||||||
|
|
||||||
extern void view_base_1 (int index, int x, int y);
|
extern void view_base_1 (int index, int x, int y);
|
||||||
extern void view_base_2 (int index, int x, int y);
|
extern void view_base_2 (int index, int x, int y);
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
#define CHAD_UNIT_LIMIT (54)
|
#define CHAD_UNIT_LIMIT (54)
|
||||||
#define CHAD_HERO_LIMIT ( 1)
|
#define CHAD_HERO_LIMIT ( 1)
|
||||||
#define CHAD_BLOCK_LIMIT (28)
|
#define CHAD_BLOCK_LIMIT (28)
|
||||||
|
#define CHAD_MODEL_LIMIT (72)
|
||||||
#define CHAD_WORLD_LIMIT ( 1)
|
#define CHAD_WORLD_LIMIT ( 1)
|
||||||
|
|
||||||
|
#define CHAD_WORLD_MODEL (120)
|
||||||
#define CHAD_WORLD_WIDTH (120)
|
#define CHAD_WORLD_WIDTH (120)
|
||||||
#define CHAD_WORLD_HEIGHT ( 60)
|
#define CHAD_WORLD_HEIGHT ( 60)
|
||||||
|
|
||||||
|
@ -3,6 +3,22 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern int snprintf (char *, unsigned long, const char *, ...);
|
||||||
|
|
||||||
|
static void limit (int * pointer, int minimum, int maximum) {
|
||||||
|
if ((* pointer >= minimum) && (* pointer <= maximum)) { return; }
|
||||||
|
if (* pointer < minimum) { * pointer = minimum; }
|
||||||
|
if (* pointer > maximum) { * pointer = maximum; }
|
||||||
|
}
|
||||||
|
|
||||||
|
static void debug (void) {
|
||||||
|
char string [64] = "";
|
||||||
|
snprintf (string, 64, "%i -- %i", camera_x, camera_y);
|
||||||
|
render_string (string, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
game_configure ();
|
game_configure ();
|
||||||
|
|
||||||
@ -17,7 +33,7 @@ int main (void) {
|
|||||||
|
|
||||||
ClearBackground (tint);
|
ClearBackground (tint);
|
||||||
|
|
||||||
view_map ();
|
view_map (camera_x, camera_y);
|
||||||
|
|
||||||
view_base_1 (0, 32, 128);
|
view_base_1 (0, 32, 128);
|
||||||
view_base_1 (1, 32, 512);
|
view_base_1 (1, 32, 512);
|
||||||
@ -31,14 +47,19 @@ int main (void) {
|
|||||||
view_unit (elf, i, 900 + 32 * i, 96);
|
view_unit (elf, i, 900 + 32 * i, 96);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (IsKeyPressed (KEY_RIGHT)) { menu_show [menu_traits] = menu_show [menu_traits] ? 0 : 1; }
|
if (IsKeyPressed (KEY_RIGHT)) { camera_x++; limit (& camera_x, 0, CHAD_WORLD_WIDTH * BASE_SIZE - render_width ()); }
|
||||||
if (IsKeyPressed (KEY_LEFT)) { menu_show [menu_skills] = menu_show [menu_skills] ? 0 : 1; }
|
if (IsKeyPressed (KEY_LEFT)) { camera_x--; limit (& camera_x, 0, CHAD_WORLD_WIDTH * BASE_SIZE - render_width ()); }
|
||||||
if (IsKeyPressed (KEY_DOWN)) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; }
|
if (IsKeyPressed (KEY_DOWN)) { camera_y++; limit (& camera_y, 0, CHAD_WORLD_HEIGHT * BASE_SIZE - render_height ()); }
|
||||||
if (IsKeyPressed (KEY_UP)) { menu_show [menu_resources] = menu_show [menu_resources] ? 0 : 1; }
|
if (IsKeyPressed (KEY_UP)) { camera_y--; limit (& camera_y, 0, CHAD_WORLD_HEIGHT * BASE_SIZE - render_height ()); }
|
||||||
|
|
||||||
|
if (IsKeyPressed (KEY_T)) { menu_show [menu_traits] = menu_show [menu_traits] ? 0 : 1; }
|
||||||
|
if (IsKeyPressed (KEY_S)) { menu_show [menu_skills] = menu_show [menu_skills] ? 0 : 1; }
|
||||||
|
if (IsKeyPressed (KEY_V)) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; }
|
||||||
|
if (IsKeyPressed (KEY_R)) { menu_show [menu_resources] = menu_show [menu_resources] ? 0 : 1; }
|
||||||
|
|
||||||
view_hud (0, SIDE_SIZE, render_height (), render_width () - SIDE_SIZE, 0);
|
view_hud (0, SIDE_SIZE, render_height (), render_width () - SIDE_SIZE, 0);
|
||||||
view_hud (1, render_width () - SIDE_SIZE, render_height (), 0, 0);
|
view_hud (1, render_width () - SIDE_SIZE, render_height (), 0, 0);
|
||||||
|
debug ();
|
||||||
view_neon_menu (menu_resources, 1, 0, 0);
|
view_neon_menu (menu_resources, 1, 0, 0);
|
||||||
|
|
||||||
view_neon_menu (menu_traits, 1, 0, 0);
|
view_neon_menu (menu_traits, 1, 0, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user