mirror of
https://github.com/Michael2-3B/Isometric-Minecraft-CE.git
synced 2024-11-30 18:24:30 +01:00
Added shadows & more block physics
Shadows are not properly implemented yet and are treated as full blocks. Block physics are also pretty rough right now, I added code so that a block placement/update can update other blocks on all sides of it, but this currently can cause a RAM clear
This commit is contained in:
parent
48c073dd7c
commit
67d0d6fbc7
BIN
screenshots/render033.gif
Normal file
BIN
screenshots/render033.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
BIN
screenshots/render034.png
Normal file
BIN
screenshots/render034.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
@ -42,4 +42,6 @@
|
|||||||
characters/steven_south_1
|
characters/steven_south_1
|
||||||
characters/steven_west_1
|
characters/steven_west_1
|
||||||
|
|
||||||
frames/selection_box
|
extras/selection_box
|
||||||
|
extras/shadow_25percent
|
||||||
|
extras/shadow_50percent
|
||||||
|
@ -3,10 +3,10 @@ opened convpng.ini
|
|||||||
--- logo_gfx (C) ---
|
--- logo_gfx (C) ---
|
||||||
building palette with [256] available indices ...
|
building palette with [256] available indices ...
|
||||||
built palette with [256] indices.
|
built palette with [256] indices.
|
||||||
palette quality : 99.23%
|
palette quality : 99.24%
|
||||||
transparent color index : 0
|
transparent color index : 0
|
||||||
transparent color : 0xFFFF
|
transparent color : 0xFFFF
|
||||||
31:
|
33:
|
||||||
water_full : 99.75%
|
water_full : 99.75%
|
||||||
water_surface : 99.76%
|
water_surface : 99.76%
|
||||||
lava_full : 98.31%
|
lava_full : 98.31%
|
||||||
@ -38,6 +38,8 @@ transparent color : 0xFFFF
|
|||||||
steven_south_1 : 99.79%
|
steven_south_1 : 99.79%
|
||||||
steven_west_1 : 99.92%
|
steven_west_1 : 99.92%
|
||||||
selection_box : 100.00%
|
selection_box : 100.00%
|
||||||
|
shadow_25percent : 100.00%
|
||||||
|
shadow_50percent : 100.00%
|
||||||
|
|
||||||
converted in 0 s
|
converted in 0 s
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |
BIN
src/gfx/extras/shadow_25percent.png
Normal file
BIN
src/gfx/extras/shadow_25percent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 B |
BIN
src/gfx/extras/shadow_50percent.png
Normal file
BIN
src/gfx/extras/shadow_50percent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 B |
@ -161,6 +161,16 @@ extern uint8_t steven_west_1_data[1163];
|
|||||||
#define selection_box_size 785
|
#define selection_box_size 785
|
||||||
extern uint8_t selection_box_data[785];
|
extern uint8_t selection_box_data[785];
|
||||||
#define selection_box ((gfx_sprite_t*)selection_box_data)
|
#define selection_box ((gfx_sprite_t*)selection_box_data)
|
||||||
|
#define shadow_25percent_width 27
|
||||||
|
#define shadow_25percent_height 29
|
||||||
|
#define shadow_25percent_size 785
|
||||||
|
extern uint8_t shadow_25percent_data[785];
|
||||||
|
#define shadow_25percent ((gfx_sprite_t*)shadow_25percent_data)
|
||||||
|
#define shadow_50percent_width 27
|
||||||
|
#define shadow_50percent_height 29
|
||||||
|
#define shadow_50percent_size 785
|
||||||
|
extern uint8_t shadow_50percent_data[785];
|
||||||
|
#define shadow_50percent ((gfx_sprite_t*)shadow_50percent_data)
|
||||||
#define sizeof_logo_gfx_pal 512
|
#define sizeof_logo_gfx_pal 512
|
||||||
extern uint16_t logo_gfx_pal[256];
|
extern uint16_t logo_gfx_pal[256];
|
||||||
|
|
||||||
|
37
src/gfx/shadow_25percent.c
Normal file
37
src/gfx/shadow_25percent.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// convpng v6.8
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "logo_gfx.h"
|
||||||
|
|
||||||
|
// 8 bpp image
|
||||||
|
uint8_t shadow_25percent_data[785] = {
|
||||||
|
27,29, // width,height
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
37
src/gfx/shadow_50percent.c
Normal file
37
src/gfx/shadow_50percent.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// convpng v6.8
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "logo_gfx.h"
|
||||||
|
|
||||||
|
// 8 bpp image
|
||||||
|
uint8_t shadow_50percent_data[785] = {
|
||||||
|
27,29, // width,height
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,
|
||||||
|
0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,
|
||||||
|
0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
256
src/main.c
256
src/main.c
@ -38,7 +38,9 @@ void blockPlacement();
|
|||||||
int gridToScreenX(int gridX, int gridZ);
|
int gridToScreenX(int gridX, int gridZ);
|
||||||
int gridToScreenY(int gridX, int gridZ, int gridY);
|
int gridToScreenY(int gridX, int gridZ, int gridY);
|
||||||
void blockPhysics();
|
void blockPhysics();
|
||||||
void addFallingBlock(int blockID, int velocity, int blockX, int blockZ, int blockY, bool flag);
|
void addFallingBlock(int blockX, int blockZ, int blockY, int velocity);
|
||||||
|
void removeFallingBlock(int blockX, int blockZ, int blockY, int index);
|
||||||
|
void updateSurroundingBlocks(int blockX, int blockZ, int blockY);
|
||||||
void print_string_centered(char *str, int y, int offset, uint8_t c);
|
void print_string_centered(char *str, int y, int offset, uint8_t c);
|
||||||
|
|
||||||
/* Put all your globals here */
|
/* Put all your globals here */
|
||||||
@ -47,17 +49,69 @@ kb_key_t key;
|
|||||||
gfx_TempSprite(behind_character, 27, 43);
|
gfx_TempSprite(behind_character, 27, 43);
|
||||||
gfx_TempSprite(behind_selection, 27, 29);
|
gfx_TempSprite(behind_selection, 27, 29);
|
||||||
|
|
||||||
int fallingBlocks[10][5] = {
|
int fallingBlocksSize = 60;
|
||||||
{-1, 0, 0, 0, 0},
|
int fallingBlocks[60][6] = {
|
||||||
{-1, 0, 0, 0, 0},
|
// {block ID, velocity, x, y, z, total fall height}
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0},
|
{-1, -1, -1, -1, -1, 0},
|
||||||
{-1, 0, 0, 0, 0}
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0},
|
||||||
|
{-1, -1, -1, -1, -1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
const gfx_sprite_t *blocks[] = {
|
const gfx_sprite_t *blocks[] = {
|
||||||
@ -159,8 +213,8 @@ const gfx_sprite_t *blocks[] = {
|
|||||||
/* 095 */ NULL,
|
/* 095 */ NULL,
|
||||||
/* 096 */ NULL,
|
/* 096 */ NULL,
|
||||||
/* 097 */ NULL,
|
/* 097 */ NULL,
|
||||||
/* 098 */ NULL,
|
/* 098 */ shadow_25percent,
|
||||||
/* 099 */ NULL,
|
/* 099 */ shadow_50percent,
|
||||||
/* 100 */ brick,
|
/* 100 */ brick,
|
||||||
/* 101 */ coal_ore,
|
/* 101 */ coal_ore,
|
||||||
/* 102 */ stone,
|
/* 102 */ stone,
|
||||||
@ -175,6 +229,9 @@ const gfx_sprite_t *blocks[] = {
|
|||||||
/* 111 */ cobblestone
|
/* 111 */ cobblestone
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SHADOW_25 98
|
||||||
|
#define SHADOW_50 99
|
||||||
|
|
||||||
#define AIR 0
|
#define AIR 0
|
||||||
#define WATER_FULL 1
|
#define WATER_FULL 1
|
||||||
#define WATER_SURFACE 2
|
#define WATER_SURFACE 2
|
||||||
@ -275,7 +332,10 @@ void main(void) {
|
|||||||
gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
|
gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
|
||||||
|
|
||||||
gfx_FillScreen(5);
|
gfx_FillScreen(5);
|
||||||
generateMap(1);
|
|
||||||
|
generateMap(1); //world 1 is a flat grass world - 2 layers of stone/coal, 1 layer of dirt, 1 layer of grass
|
||||||
|
//DO NOT LOAD MAP 3. IT IS A FLOATING SAND WORLD AND IF YOU MESS WITH THE SAND YOU WILL (CURRENTLY) GET A RAM CLEAR
|
||||||
|
|
||||||
drawMap(0,0,0);
|
drawMap(0,0,0);
|
||||||
|
|
||||||
playerX = gridToScreenX(playerGridA, playerGridB);
|
playerX = gridToScreenX(playerGridA, playerGridB);
|
||||||
@ -317,8 +377,7 @@ void main(void) {
|
|||||||
/* Put other functions here */
|
/* Put other functions here */
|
||||||
|
|
||||||
void generateMap(int mapNum){
|
void generateMap(int mapNum){
|
||||||
if(mapNum == 0){
|
if(mapNum == 0){ //dynamic terrain
|
||||||
//generate heightmap
|
|
||||||
int lowVal = -1;
|
int lowVal = -1;
|
||||||
int highVal = 1;
|
int highVal = 1;
|
||||||
int heightMap[sizeX][sizeZ];
|
int heightMap[sizeX][sizeZ];
|
||||||
@ -387,7 +446,7 @@ void generateMap(int mapNum){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if(mapNum == 1){
|
} else if(mapNum == 1){ //flat grass world
|
||||||
for(a=0; a<sizeX; a++){
|
for(a=0; a<sizeX; a++){
|
||||||
for(b=0; b<sizeZ; b++){
|
for(b=0; b<sizeZ; b++){
|
||||||
for(c=0; c<sizeY; c++){
|
for(c=0; c<sizeY; c++){
|
||||||
@ -407,7 +466,7 @@ void generateMap(int mapNum){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mapNum == 2){
|
} else if(mapNum == 2){ //empty world
|
||||||
for(a=0; a<sizeX; a++){
|
for(a=0; a<sizeX; a++){
|
||||||
for(b=0; b<sizeZ; b++){
|
for(b=0; b<sizeZ; b++){
|
||||||
for(c=0; c<sizeY; c++){
|
for(c=0; c<sizeY; c++){
|
||||||
@ -415,6 +474,22 @@ void generateMap(int mapNum){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(mapNum == 3){ //floating sand world
|
||||||
|
for(a=0; a<sizeX; a++){
|
||||||
|
for(b=0; b<sizeZ; b++){
|
||||||
|
for(c=0; c<sizeY; c++){
|
||||||
|
if(c==0){
|
||||||
|
map[a][b][c] = STONE;
|
||||||
|
} else if(c==1 && a>3 && b>3){
|
||||||
|
map[a][b][c] = SHADOW_50;
|
||||||
|
} else if(c==7 && a>3 && b>3){
|
||||||
|
map[a][b][c] = SAND;
|
||||||
|
} else {
|
||||||
|
map[a][b][c] = AIR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,6 +724,17 @@ void blockPlacement(){
|
|||||||
|
|
||||||
if(map[selectionA][selectionB][selectionC] != i){
|
if(map[selectionA][selectionB][selectionC] != i){
|
||||||
map[selectionA][selectionB][selectionC] = i;
|
map[selectionA][selectionB][selectionC] = i;
|
||||||
|
|
||||||
|
if(selectionC>0){
|
||||||
|
if(map[selectionA][selectionB][selectionC-1] == AIR){
|
||||||
|
j=selectionC-1;
|
||||||
|
while(map[selectionA][selectionB][j] == AIR && j>-1) j--;
|
||||||
|
|
||||||
|
map[selectionA][selectionB][j+1] = SHADOW_50;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
gfx_FillScreen(5);
|
gfx_FillScreen(5);
|
||||||
drawMap(0,0,0);
|
drawMap(0,0,0);
|
||||||
drawBlockSelection();
|
drawBlockSelection();
|
||||||
@ -662,22 +748,25 @@ void blockPlacement(){
|
|||||||
|
|
||||||
gfx_BlitBuffer();
|
gfx_BlitBuffer();
|
||||||
|
|
||||||
|
updateSurroundingBlocks(selectionA, selectionB, selectionC);
|
||||||
|
|
||||||
|
/*
|
||||||
//falling blocks
|
//falling blocks
|
||||||
if(i==AIR && selectionC<sizeY-1){
|
if(i==AIR && selectionC<sizeY-1){
|
||||||
if(map[selectionA][selectionB][selectionC+1] == SAND || map[selectionA][selectionB][selectionC+1] == GRAVEL){
|
if(map[selectionA][selectionB][selectionC+1] == SAND || map[selectionA][selectionB][selectionC+1] == GRAVEL){
|
||||||
j = 0;
|
//deleted a block, so now updating surrounding blocks
|
||||||
while(fallingBlocks[j][0] != -1) j++;
|
|
||||||
|
|
||||||
addFallingBlock(map[selectionA][selectionB][selectionC+1], 1, selectionA, selectionB, selectionC+1, false);
|
updateSurroundingBlocks(selectionA, selectionB, selectionC);
|
||||||
}
|
}
|
||||||
} else if((i==SAND || i==GRAVEL) && selectionC>0){
|
} else if((i==SAND || i==GRAVEL) && selectionC>0){
|
||||||
if(map[selectionA][selectionB][selectionC-1] == AIR){
|
if(map[selectionA][selectionB][selectionC-1] == AIR){
|
||||||
j = 0;
|
//placed a gravity block
|
||||||
while(fallingBlocks[j][0] != -1) j++;
|
addFallingBlock(selectionA, selectionB, selectionC, 1);
|
||||||
|
|
||||||
addFallingBlock(i, 1, selectionA, selectionB, selectionC, false);
|
updateSurroundingBlocks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -694,28 +783,36 @@ int gridToScreenY(int gridX, int gridZ, int gridY){
|
|||||||
void blockPhysics(){
|
void blockPhysics(){
|
||||||
int blockX, blockZ, blockY;
|
int blockX, blockZ, blockY;
|
||||||
|
|
||||||
for(j=0; j<10; j++){
|
for(j=0; j<fallingBlocksSize; j++){
|
||||||
if(fallingBlocks[j][0] != -1){
|
if(fallingBlocks[j][0] != -1){
|
||||||
blockX = fallingBlocks[j][2];
|
blockX = fallingBlocks[j][2];
|
||||||
blockZ = fallingBlocks[j][3];
|
blockZ = fallingBlocks[j][3];
|
||||||
blockY = fallingBlocks[j][4];
|
blockY = fallingBlocks[j][4];
|
||||||
|
|
||||||
|
|
||||||
if(blockY > 0){
|
if(blockY > 0){
|
||||||
if(map[blockX][blockZ][blockY-1] == AIR){
|
if(map[blockX][blockZ][blockY-1] == AIR){
|
||||||
map[blockX][blockZ][blockY] = AIR;
|
map[blockX][blockZ][blockY] = AIR;
|
||||||
|
if(fallingBlocks[j][5] == 0)
|
||||||
|
updateSurroundingBlocks(blockX, blockZ, blockY);
|
||||||
|
|
||||||
if(blockY+1<sizeY){
|
if(blockY+1<sizeY){
|
||||||
if(map[blockX][blockZ][blockY+1] == SAND || map[blockX][blockZ][blockY+1] == GRAVEL)
|
if(map[blockX][blockZ][blockY+1] == SAND || map[blockX][blockZ][blockY+1] == GRAVEL)
|
||||||
addFallingBlock(map[blockX][blockZ][blockY+1], 1, blockX, blockZ, blockY+1, true);
|
addFallingBlock(blockX, blockZ, blockY+1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fallingBlocks[j][4] -= fallingBlocks[j][1];
|
fallingBlocks[j][4] -= fallingBlocks[j][1];
|
||||||
map[blockX][blockZ][fallingBlocks[j][4]] = fallingBlocks[j][0];
|
|
||||||
|
fallingBlocks[j][5]++;
|
||||||
|
|
||||||
|
map[blockX][blockZ][blockY-1] = fallingBlocks[j][0];
|
||||||
} else {
|
} else {
|
||||||
addFallingBlock(-1, 0, 0, 0, 0, false);
|
removeFallingBlock(blockX, blockZ, blockY, j);
|
||||||
|
updateSurroundingBlocks(blockX, blockZ, blockY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addFallingBlock(-1, 0, 0, 0, 0, false);
|
removeFallingBlock(blockX, blockZ, blockY, j);
|
||||||
|
updateSurroundingBlocks(blockX, blockZ, blockY);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx_FillScreen(5);
|
gfx_FillScreen(5);
|
||||||
@ -732,23 +829,92 @@ void blockPhysics(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFallingBlock(int blockID, int velocity, int blockX, int blockZ, int blockY, bool flag){
|
void addFallingBlock(int blockX, int blockZ, int blockY, int velocity){
|
||||||
if(flag == true){
|
|
||||||
int iter = 0;
|
|
||||||
while(fallingBlocks[iter][0] != -1) iter++;
|
|
||||||
|
|
||||||
fallingBlocks[iter][0] = blockID;
|
int index = 0;
|
||||||
fallingBlocks[iter][1] = velocity;
|
while(fallingBlocks[index][0] != -1) index++;
|
||||||
fallingBlocks[iter][2] = blockX;
|
|
||||||
fallingBlocks[iter][3] = blockZ;
|
|
||||||
fallingBlocks[iter][4] = blockY;
|
|
||||||
|
|
||||||
} else {
|
fallingBlocks[index][0] = map[blockX][blockZ][blockY]; //block ID
|
||||||
fallingBlocks[j][0] = blockID;
|
fallingBlocks[index][1] = velocity;
|
||||||
fallingBlocks[j][1] = velocity;
|
fallingBlocks[index][2] = blockX;
|
||||||
fallingBlocks[j][2] = blockX;
|
fallingBlocks[index][3] = blockZ;
|
||||||
fallingBlocks[j][3] = blockZ;
|
fallingBlocks[index][4] = blockY;
|
||||||
fallingBlocks[j][4] = blockY;
|
|
||||||
|
fallingBlocks[index][5] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeFallingBlock(int blockX, int blockZ, int blockY, int index){
|
||||||
|
|
||||||
|
fallingBlocks[index][0] = -1;
|
||||||
|
fallingBlocks[index][1] = -1;
|
||||||
|
fallingBlocks[index][2] = -1;
|
||||||
|
fallingBlocks[index][3] = -1;
|
||||||
|
fallingBlocks[index][4] = -1;
|
||||||
|
|
||||||
|
fallingBlocks[index][5] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateSurroundingBlocks(int blockX, int blockZ, int blockY){
|
||||||
|
|
||||||
|
if(blockY>1){
|
||||||
|
if(map[blockX][blockZ][blockY-1] == SAND || map[blockX][blockZ][blockY-1] == GRAVEL){
|
||||||
|
if(map[blockX][blockZ][blockY-2] == AIR)
|
||||||
|
addFallingBlock(blockX, blockZ, blockY-1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blockX>0){
|
||||||
|
if(map[blockX-1][blockZ][blockY] == SAND || map[blockX-1][blockZ][blockY] == GRAVEL){
|
||||||
|
if(blockY>0){
|
||||||
|
if(map[blockX-1][blockZ][blockY-1] == AIR)
|
||||||
|
addFallingBlock(blockX-1, blockZ, blockY, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blockZ>0){
|
||||||
|
if(map[blockX][blockZ-1][blockY] == SAND || map[blockX][blockZ-1][blockY] == GRAVEL){
|
||||||
|
if(blockY>0){
|
||||||
|
if(map[blockX][blockZ-1][blockY-1] == AIR)
|
||||||
|
addFallingBlock(blockX, blockZ-1, blockY, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(map[blockX][blockZ][blockY] == SAND || map[blockX][blockZ][blockY] == GRAVEL){
|
||||||
|
if(blockY>0){
|
||||||
|
if(map[blockX][blockZ][blockY-1] == AIR){
|
||||||
|
addFallingBlock(blockX, blockZ, blockY, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blockZ<sizeZ-1){
|
||||||
|
if(map[blockX][blockZ+1][blockY] == SAND || map[blockX][blockZ+1][blockY] == GRAVEL){
|
||||||
|
if(blockY>0){
|
||||||
|
if(map[blockX][blockZ+1][blockY-1] == AIR)
|
||||||
|
addFallingBlock(blockX, blockZ+1, blockY, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blockX<sizeX-1){
|
||||||
|
if(map[blockX+1][blockZ][blockY] == SAND || map[blockX+1][blockZ][blockY] == GRAVEL){
|
||||||
|
if(blockY>0){
|
||||||
|
if(map[blockX+1][blockZ][blockY-1] == AIR)
|
||||||
|
addFallingBlock(blockX+1, blockZ, blockY, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blockY<sizeY-1){
|
||||||
|
if(map[blockX][blockZ][blockY+1] == SAND || map[blockX][blockZ][blockY+1] == GRAVEL){
|
||||||
|
if(blockY>0){
|
||||||
|
if(map[blockX][blockZ][blockY] == AIR)
|
||||||
|
addFallingBlock(blockX, blockZ, blockY+1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user