Compare commits

...

3 Commits

26 changed files with 728 additions and 332 deletions

View File

@ -15,39 +15,27 @@ find_package(LibProf 2.4 REQUIRED)
fxconv_declare_converters(assets-cg/converters.py)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/level1.json"
COMMENT "Convert Tiled TMX map to usable JSON file"
COMMENT "Convert Tiled TMX map to usable JSON file"
COMMAND tiled --export-tileset json tilesetnpp.tsx tilesetnpp.json
COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json'
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/
DEPENDS assets-cg/levels/level1.tmx
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/level2.json"
COMMENT "Convert Tiled TMX map to usable JSON file"
COMMAND tiled --export-tileset json tilesetnpp.tsx tilesetnpp.json
COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json'
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/
DEPENDS assets-cg/levels/level2.tmx
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/level1.json"
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/level2.json"
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/level3.json"
COMMENT "Convert Tiled TMX map to usable JSON file"
COMMAND tiled --export-tileset json tilesetnpp.tsx tilesetnpp.json
COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json'
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-cg/levels/
DEPENDS assets-cg/levels/level3.tmx
assets-cg/converters.py
DEPENDS assets-cg/converters.py
assets-cg/levels/tileset.png
assets-cg/levels/tilesetnpp.tsx)
assets-cg/levels/tilesetnpp.tsx
assets-cg/levels/level1.tmx
assets-cg/levels/level2.tmx
assets-cg/levels/level2.tmx)
set(SOURCES
src/main.cpp
src/extrakeyboard.cpp
src/utilities.cpp
src/player.cpp
src/background.cpp
src/level.cpp
# ...
)
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
@ -62,6 +50,8 @@ set(ASSETS_cg
#assets-cg/sprites/running.png
#assets-cg/sprites/static.png
assets-cg/sprites/rectangle.png
assets-cg/sprites/circle.png
assets-cg/sprites/selected.png
assets-cg/levels/tileset.png
assets-cg/levels/level1.json

View File

@ -15,13 +15,13 @@
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":14,
"id":2,
"name":"Foreground",
"opacity":1,
"type":"tilelayer",
"visible":true,
"visible":false,
"width":25,
"x":0,
"y":0

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.8" tiledversion="1.8.0" orientation="orthogonal" renderorder="right-down" width="25" height="14" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="1">
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="25" height="14" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="1">
<tileset firstgid="1" source="tilesetnpp.tsx"/>
<layer id="1" name="Background" width="25" height="14">
<data encoding="csv">
@ -19,21 +19,21 @@
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
<layer id="2" name="Foreground" width="25" height="14">
<layer id="2" name="Foreground" width="25" height="14" visible="0">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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 0, 2, 2, 0, 0, 0, 36, 2, 35, 0, 0, 0, 2, 2, 0, 0, 0, 0, 26, 27, 38, 35, 0, 0, 17, 18, 2, 2, 27, 0, 0, 0, 2, 0, 0, 0, 28, 2, 2, 15, 16, 0, 0, 36, 37, 2, 0, 0, 14, 2, 2, 2, 2, 37, 0, 0, 0, 0, 0, 0, 0, 38, 2, 2, 2, 2, 13, 0, 0, 2, 2, 0, 0, 4, 2, 2, 2, 2, 2, 15, 16, 0, 0, 0, 17, 18, 2, 2, 2, 2, 2, 3, 0, 0, 2, 26, 27, 0, 0, 7, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6, 0, 0, 28, 25, 36, 37, 0, 0, 0, 0, 4, 2, 5, 6, 0, 0, 0, 0, 0, 7, 8, 2, 3, 0, 0, 0, 0, 38, 35, 0, 4, 13, 0, 0, 0, 0, 21, 0, 0, 0, 14, 2, 13, 0, 0, 0, 21, 0, 0, 0, 0, 14, 3, 0, 0, 0, 4, 13, 0, 0, 0, 21, 0, 0, 14, 2, 2, 2, 13, 0, 0, 21, 0, 0, 0, 14, 3, 0, 0, 0, 0, 0, 4, 15, 16, 0, 21, 17, 18, 5, 6, 0, 7, 8, 15, 16, 21, 0, 17, 18, 3, 0, 0, 0, 0, 0, 0, 0, 7, 8, 2, 2, 5, 6, 0, 0, 0, 0, 0, 7, 8, 2, 2, 5, 6, 0, 0, 0, 0],
"height":14,
"id":1,
"name":"Background",
"opacity":1,
"type":"tilelayer",
"visible":true,
"visible":false,
"width":25,
"x":0,
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0, 0, 0, 42, 31, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":14,
"id":2,
"name":"Foreground",

View File

@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="25" height="14" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="1">
<tileset firstgid="1" source="tilesetnpp.tsx"/>
<layer id="1" name="Background" width="25" height="14">
<layer id="1" name="Background" width="25" height="14" visible="0">
<data encoding="csv">
1,1,1,1,23,24,2,2,21,22,1,1,1,1,1,23,24,2,2,21,22,1,1,1,1,
1,1,1,20,5,6,0,34,7,8,21,22,1,23,24,5,6,34,0,7,8,19,1,1,1,
1,1,20,3,0,0,0,34,0,0,4,2,2,2,3,0,0,34,0,0,0,4,19,1,1,
1,20,3,0,0,0,0,34,0,0,0,10,2,9,0,0,0,34,0,0,0,0,4,19,1,
42,9,0,0,0,0,2,2,0,0,0,26,2,25,0,0,0,2,2,1,1,1,1,10,41,
58,25,0,0,23,24,2,2,41,0,0,0,2,0,0,0,42,2,2,21,22,0,0,26,57,
2,0,0,20,2,2,2,2,57,0,0,0,0,0,0,0,58,2,2,2,2,19,0,0,2,
2,0,0,4,2,2,2,2,2,21,22,0,0,0,23,24,2,2,2,2,2,3,0,0,2,
10,41,0,0,7,8,2,2,2,2,2,2,2,2,2,2,2,2,2,5,6,0,0,42,9,
26,57,0,0,0,0,4,2,5,6,0,0,0,0,0,7,8,2,3,0,0,0,0,58,25,
1,4,19,0,0,0,0,33,0,0,0,20,2,19,0,0,0,33,0,0,0,0,20,3,1,
1,1,4,19,0,0,0,33,0,0,20,2,2,2,19,0,0,33,0,0,0,20,3,1,1,
1,1,1,4,21,22,0,33,23,24,5,6,1,7,8,21,22,33,0,23,24,3,1,1,1,
1,1,1,1,7,8,2,2,5,6,1,1,1,1,1,7,8,2,2,5,6,1,1,1,1
0,0,0,0,17,18,2,2,15,16,0,0,0,0,0,17,18,2,2,15,16,0,0,0,0,
0,0,0,14,5,6,22,0,7,8,15,16,0,17,18,5,6,22,0,7,8,13,0,0,0,
0,0,14,3,0,0,22,0,0,0,4,2,2,2,3,0,0,22,0,0,0,4,13,0,0,
0,14,3,0,0,0,22,0,0,0,0,26,2,25,0,0,0,22,0,0,0,0,4,13,0,
28,25,0,0,0,0,2,2,0,0,0,36,2,35,0,0,0,2,2,0,0,0,0,26,27,
38,35,0,0,17,18,2,2,27,0,0,0,2,0,0,0,28,2,2,15,16,0,0,36,37,
2,0,0,14,2,2,2,2,37,0,0,0,0,0,0,0,38,2,2,2,2,13,0,0,2,
2,0,0,4,2,2,2,2,2,15,16,0,0,0,17,18,2,2,2,2,2,3,0,0,2,
26,27,0,0,7,8,2,2,2,2,2,2,2,2,2,2,2,2,2,5,6,0,0,28,25,
36,37,0,0,0,0,4,2,5,6,0,0,0,0,0,7,8,2,3,0,0,0,0,38,35,
0,4,13,0,0,0,0,21,0,0,0,14,2,13,0,0,0,21,0,0,0,0,14,3,0,
0,0,4,13,0,0,0,21,0,0,14,2,2,2,13,0,0,21,0,0,0,14,3,0,0,
0,0,0,4,15,16,0,21,17,18,5,6,0,7,8,15,16,21,0,17,18,3,0,0,0,
0,0,0,0,7,8,2,2,5,6,0,0,0,0,0,7,8,2,2,5,6,0,0,0,0
</data>
</layer>
<layer id="2" name="Foreground" width="25" height="14">
@ -24,17 +24,17 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,66,0,0,0,0,66,0,0,0,66,0,0,0,0,66,0,0,0,0,0,
0,0,0,0,66,0,0,0,0,0,66,0,0,0,66,0,0,0,0,0,66,49,0,0,0,
0,0,0,66,0,0,0,0,0,0,66,0,0,0,66,0,0,0,0,0,0,66,0,0,0,
0,0,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,0,0,
0,0,66,0,0,0,0,0,0,0,0,0,65,0,0,0,0,0,0,0,0,0,66,0,0,
0,0,0,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,0,0,0,
0,0,0,0,66,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,66,0,0,0,0,
0,0,0,0,0,66,0,0,0,0,1,1,1,1,1,0,0,0,0,66,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0
0,0,0,0,0,42,0,0,0,0,42,0,0,0,42,0,0,0,0,42,0,0,0,0,0,
0,0,0,0,42,0,0,0,0,0,42,0,0,0,42,0,0,0,0,0,42,31,0,0,0,
0,0,0,42,0,0,0,0,0,0,42,0,0,0,42,0,0,0,0,0,0,42,0,0,0,
0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,0,0,
0,0,42,0,0,0,0,0,0,0,0,0,41,0,0,0,0,0,0,0,0,0,42,0,0,
0,0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,0,0,0,
0,0,0,0,42,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,42,0,0,0,0,
0,0,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0,42,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -1,11 +1,11 @@
{ "columns":16,
{ "columns":10,
"image":"tileset.png",
"imageheight":256,
"imagewidth":256,
"imageheight":80,
"imagewidth":160,
"margin":0,
"name":"tileset",
"spacing":0,
"tilecount":256,
"tilecount":50,
"tiledversion":"1.8.0",
"tileheight":16,
"tilewidth":16,

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.1" name="tileset" tilewidth="16" tileheight="16" tilecount="256" columns="16">
<image source="tileset.png" width="256" height="256"/>
<tileset version="1.10" tiledversion="1.10.1" name="tileset" tilewidth="16" tileheight="16" tilecount="50" columns="10">
<image source="tileset.png" width="160" height="80"/>
</tileset>

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

4
build
View File

@ -1,3 +1 @@
rm -r build-cg
rm *.g3a
fxsdk build-cg -B VERBOSE=1
fxsdk build-cg VERBOSE=1

3
buildpush Executable file
View File

@ -0,0 +1,3 @@
rm -r build-cg
rm *.g3a
fxsdk build-cg-push -s VERBOSE=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -1,97 +0,0 @@
#include "background.h"
#include "player.h"
#include <azur/azur.h>
#include <azur/gint/render.h>
#include <cstdint>
#include <stdlib.h>
extern struct Map map_level1;
extern struct Map map_level2;
extern struct Map map_level3;
extern bool drawbackground;
struct Map *map_level;
Background::Background( )
{
map_level = &map_level2;
}
Background::~Background( )
{
}
void Background::ChangeMap( int level, Player *MyPlayer )
{
if(level==1) map_level = &map_level1;
else if(level==2) map_level = &map_level2;
else if(level==3) map_level = &map_level3;
else map_level = &map_level1;
UpdateDataMap( MyPlayer );
}
void Background::UpdateDataMap( Player *MyPlayer )
{
for(int i=0; i<map_level->w; i++)
{
for(int j=0; j<=map_level->h; j++)
{
uint16_t index = (j) * map_level->w + (i) % map_level->w;
uint16_t currentTile = map_level->layers[1][ index ];
if (currentTile==11)
{
MyPlayer->x = libnum::num( i*16 - 4 + 8 );
MyPlayer->y = libnum::num( j*16 + 8 );
MyPlayer->vx = 0;
MyPlayer->vy = 0;
MyPlayer->Update( 0.0f, 0.0f, 0.0f );
}
}
}
}
void Background::Render( void )
{
for(int u=!drawbackground; u<map_level->nblayers;u++)
{
for(int i=0; i<map_level->w; i++)
{
for(int j=0; j<=map_level->h; j++)
{
uint16_t index = (j) * map_level->w + (i) % map_level->w;
uint16_t currentTile = map_level->layers[u][ index ];
if (currentTile!=0 && currentTile!=11)
{
uint16_t xtile = ((currentTile % map_level->tileset_size)-1) * 16;
uint16_t ytile = (currentTile / map_level->tileset_size) * 16;
azrp_subimage_p8( i*16-4, j*16, map_level->tileset, xtile, ytile, 16, 16, DIMAGE_NONE );
}
}
}
}
}
void Background::Update( float dt )
{
}
bool Background::CanGo( Player *MyPlayer )
{
int tileX = ((int) MyPlayer->x+4) >> 4 ;
int tileY = ((int) MyPlayer->y+8) >> 4;
int tileIndex = tileY*map_level->w + tileX;
int tileValue = map_level->layers[0][ tileIndex ];
if (tileValue==0 || tileValue==1) return true;
else return false;
}

195
src/level.cpp Normal file
View File

@ -0,0 +1,195 @@
#include "level.h"
#include "player.h"
#include <azur/azur.h>
#include <azur/gint/render.h>
#include "utilities.h"
#include <cstdint>
#include <stdlib.h>
#define TILESIZE 16
extern struct Map map_level1;
extern struct Map map_level2;
extern struct Map map_level3;
extern bool drawbackground;
struct Map *map_level;
int tileXmin, tileXmax;
int tileYmin, tileYmax;
int XinTile, YinTile;
extern bopti_image_t img_selected;
Level::Level( )
{
map_level = &map_level1;
}
Level::~Level( )
{
}
void Level::ChangeMap( int level, Player *MyPlayer )
{
if(level==1) map_level = &map_level1;
else if(level==2) map_level = &map_level2;
else if(level==3) map_level = &map_level3;
else map_level = &map_level1;
this->UpdateDataMap( MyPlayer );
}
void Level::UpdateDataMap( Player *MyPlayer )
{
for(int i=0; i<map_level->w; i++)
{
for(int j=0; j<map_level->h; j++)
{
uint16_t index = j * map_level->w + i;
uint16_t currentTile = map_level->layers[1][ index ];
if (currentTile==32)
{
MyPlayer->x = (float) (i*16+8);
MyPlayer->y = (float) (j*16);
MyPlayer->vx = 0.0f;
MyPlayer->vy = 0.0f;
MyPlayer->Update( 0.0f );
}
}
}
}
void Level::Render( void )
{
for(int u=!drawbackground; u<map_level->nblayers;u++)
{
for(int i=0; i<map_level->w; i++)
{
for(int j=0; j<map_level->h; j++)
{
uint16_t index = j * map_level->w + i;
uint16_t currentTile = map_level->layers[u][ index ];
if (currentTile!=0) // && currentTile!=32)
{
uint16_t xtile = ((currentTile % map_level->tileset_size)-1) * 16;
uint16_t ytile = (currentTile / map_level->tileset_size) * 16;
azrp_subimage_p8( i*16, j*16, map_level->tileset, xtile, ytile, 16, 16, DIMAGE_NONE );
// TODO :
// the last column of tile is not fully drawn cause 4 pixels are missing
// to upgrade the
/*
if (u==0) Azur_draw_text( i*16+1, j*16+1, "%d", GetTileBackgroundINT( i, j ) );
else if (u==1) Azur_draw_text( i*16+1, j*16+1, "%d", GetTileForegroundINT( i, j ) );
*/
}
}
}
}
}
void Level::RenderSelected( void )
{
for(int i=tileXmin; i<=tileXmax; i++)
{
for(int j=tileYmin; j<=tileYmax; j++)
{
azrp_image_p8( i*16, j*16, &img_selected, DIMAGE_NONE );
}
}
}
void Level::Update( float dt )
{
}
int Level::GetTileBackgroundINT( uint8_t x, uint8_t y )
{
uint16_t index = y * map_level->w + x;
uint16_t currentTile = map_level->layers[0][ index ];
return currentTile;
}
int Level::GetTileForegroundINT( uint8_t x, uint8_t y )
{
uint16_t index = y * map_level->w + x;
uint16_t currentTile = map_level->layers[1][ index ];
return currentTile;
}
int Level::GetTileBackground( uint8_t x, uint8_t y )
{
uint8_t tileX = x / 16;
uint8_t tileY = y / 16;
uint16_t index = tileY * map_level->w + tileX;
uint16_t currentTile = map_level->layers[0][ index ];
return currentTile;
}
int Level::GetTileForeground( uint8_t x, uint8_t y )
{
uint8_t tileX = x / 16;
uint8_t tileY = y / 16;
uint16_t index = tileY * map_level->w + tileX;
uint16_t currentTile = map_level->layers[1][ index ];
return currentTile;
}
bool Level::CanGo( Player *MyPlayer )
{
int tileX, tileY;
int tileIndex, tileValue;
int xmin = (int) MyPlayer->nextx - 8;
int ymin = (int) MyPlayer->nexty - 8;
int xmax = (int) MyPlayer->nextx + 8;
int ymax = (int) MyPlayer->nexty + 8;
/*
tileXmin = xmin / 16;
tileXmax = xmax / 16;
tileYmin = ymin / 16;
tileYmax = ymax / 16;
XinTile = xmin % 16;
YinTile = ymin % 16;
*/
/*
if ((MyPlayer->action == RUN || MyPlayer->action == WALK) && MyPlayer->direction == LEFT)
{
if( GetTileBackground( xmin, ymin ) != 0 || GetTileBackground( xmin, ymax ) != 0) return false;
}
else if ((MyPlayer->action == RUN || MyPlayer->action == WALK) && MyPlayer->direction == RIGHT)
{
if( GetTileBackground( xmax, ymax ) != 0 || GetTileBackground( xmin, ymax ) != 0) return false;
}
else if (MyPlayer->action == JUMP)
{
if( GetTileBackground( xmin, ymin ) != 0 || GetTileBackground( xmax, ymin ) != 0) return false;
}
else if (MyPlayer->action == FALL)
{
if( GetTileBackground( xmin, ymax ) != 0 || GetTileBackground( xmax, ymax ) != 0) return false;
}
*/
return true;
}

View File

@ -25,19 +25,26 @@ struct Map {
};
class Background
class Level
{
public:
Background( );
~Background( );
Level( );
~Level( );
void Update( float dt );
void Render( );
void Render( void );
void RenderSelected( void );
void ChangeMap( int level, Player *MyPlayer );
void UpdateDataMap( Player *MyPlayer );
bool CanGo( Player *MyPlayer );
private:
int GetTileBackground( uint8_t x, uint8_t y );
int GetTileForeground( uint8_t x, uint8_t y );
int GetTileBackgroundINT( uint8_t x, uint8_t y );
int GetTileForegroundINT( uint8_t x, uint8_t y );
};

View File

@ -27,14 +27,14 @@
#include "utilities.h"
#include "player.h"
#include "background.h"
#include "level.h"
bool screenshot = false;
bool record = false;
bool textoutput = false;
bool exitToOS = false;
uint8_t texttodraw=1;
uint8_t texttodraw=0;
#define SCALE_PIXEL 1
@ -53,7 +53,7 @@ kmalloc_gint_stats_t *extram_stats;
KeyboardExtra MyKeyboard;
Background MyBackground;
Level MyLevel;
Player MyPlayer( 198, 180 );
@ -95,24 +95,23 @@ static void hook_prefrag(int id, void *fragment, int size)
static void update( float dt )
{
MyPlayer.Update( dt, 0.0f, 1.0f );
MyPlayer.Update( dt );
}
static void render( void )
{
MyBackground.Render();
MyLevel.Render();
// MyLevel.RenderSelected();
MyPlayer.Render();
#if(BIAS)
if (texttodraw>=1) Azur_draw_text(1,01, "FPS = %.0f", (float) (1000000.0f / elapsedTime) );
//if (texttodraw>=1) Azur_draw_text(1,11, "Part.= %d - Bull.= %d", MyParticles.size(), MyPlayerBullets.size() );
//if (texttodraw>=1 && !MyEnemies.empty()) Azur_draw_text(1,21, "Ennmy Life= %d", MyEnemies[0]->life );
if (texttodraw>=1) Azur_draw_text(1,01, "FPS = %.0f", (float) (1000.0f / elapsedTime) );
if (texttodraw>=2) Azur_draw_text(1,31, "Update = %.3f ms", (float) time_update / 1000.0f );
if (texttodraw>=2) Azur_draw_text(1,41, "Render = %.3f ms", (float) time_render / 1000.0f );
if (texttodraw>=2) Azur_draw_text(1,51, ">Total = %.0f ms", (float) elapsedTime / 1000.0f );
if (texttodraw>=2) Azur_draw_text(1,51, ">Total = %.0f ms", (float) elapsedTime );
if (texttodraw>=3) Azur_draw_text(1,81, "Mem Used : %d", _uram_stats->used_memory + extram_stats->used_memory);
if (texttodraw>=3) Azur_draw_text(1,91, "Mem Free : %d", _uram_stats->free_memory + extram_stats->free_memory);
@ -129,26 +128,24 @@ static void get_inputs( float dt )
#if(DEBUG_MODE)
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_7) && usb_is_open() ) {screenshot = true;};
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_8) && usb_is_open()) {record = true; };
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_9) && usb_is_open()) {record = false; };
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_7) && usb_is_open() ) {screenshot = true;};
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_8) && usb_is_open() ) {record = true; };
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_9) && usb_is_open() ) {record = false; };
if(MyKeyboard.IsKeyPressedEvent(MYKEY_VARS)) { drawbackground = !drawbackground; }
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_VARS) ) { drawbackground = !drawbackground; }
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F1)) { texttodraw = 0; }
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F2)) { texttodraw = 1; }
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F3)) { texttodraw = 2; }
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F4)) { texttodraw = 3; }
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_F1) ) { texttodraw = 0; }
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_F2) ) { texttodraw = 1; }
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_F3) ) { texttodraw = 2; }
if( MyKeyboard.IsKeyPressed(MYKEY_OPTN) && MyKeyboard.IsKeyPressedEvent(MYKEY_F4) ) { texttodraw = 3; }
if(MyKeyboard.IsKeyPressedEvent(MYKEY_F1)) { MyBackground.ChangeMap(1, &MyPlayer); }
if(MyKeyboard.IsKeyPressedEvent(MYKEY_F2)) { MyBackground.ChangeMap(2, &MyPlayer); }
if(MyKeyboard.IsKeyPressedEvent(MYKEY_F3)) { MyBackground.ChangeMap(3, &MyPlayer); }
if(MyKeyboard.IsKeyPressedEvent(MYKEY_F4)) { MyBackground.ChangeMap(4, &MyPlayer); }
if(MyKeyboard.IsKeyPressedEvent(MYKEY_F5)) { MyBackground.ChangeMap(5, &MyPlayer); }
if(MyKeyboard.IsKeyPressedEvent(MYKEY_F6)) { MyBackground.ChangeMap(6, &MyPlayer); }
if( MyKeyboard.IsKeyPressedEvent(MYKEY_F1) ) { MyLevel.ChangeMap(1, &MyPlayer); }
if( MyKeyboard.IsKeyPressedEvent(MYKEY_F2) ) { MyLevel.ChangeMap(2, &MyPlayer); }
if( MyKeyboard.IsKeyPressedEvent(MYKEY_F3) ) { MyLevel.ChangeMap(3, &MyPlayer); }
#endif
/*
if(MyKeyboard.IsKeyPressed(MYKEY_ALPHA) && MyKeyboard.IsKeyPressed(MYKEY_LEFT))
{
MyPlayer.Walk_Left( dt );
@ -157,7 +154,9 @@ static void get_inputs( float dt )
{
MyPlayer.Walk_Right( dt );
}
else if(MyKeyboard.IsKeyPressed(MYKEY_LEFT))
else
*/
if(MyKeyboard.IsKeyPressed(MYKEY_LEFT))
{
MyPlayer.Run_Left( dt );
}
@ -170,7 +169,7 @@ static void get_inputs( float dt )
MyPlayer.No_Order( dt );
}
if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT))
if(MyKeyboard.IsKeyPressedEvent(MYKEY_SHIFT))
{
MyPlayer.Jump( dt );
}
@ -256,6 +255,9 @@ int main(void)
usb_interface_t const *interfaces[] = { &usb_ff_bulk, NULL };
usb_open(interfaces, GINT_CALL_NULL);
//MyLevel.ChangeMap(2, &MyPlayer);
prof_init();
do
@ -284,7 +286,7 @@ int main(void)
{
// all the stuff to be rendered should be put here
azrp_clear( C_WHITE );
azrp_clear( C_GREEN );
render();
azrp_update();
}
@ -292,7 +294,7 @@ int main(void)
prof_leave(perf_render);
time_render = prof_time(perf_render);
elapsedTime = ((float) (time_update+time_render));
elapsedTime = ((float) (time_update+time_render)) / 1000.0f ;
}
while (exitToOS==false);

255
src/player copy.cpp Normal file
View File

@ -0,0 +1,255 @@
#include "player.h"
#include <num/num.h>
#include <gint/rtc.h>
#include "level.h"
#include "utilities.h"
/*
extern bopti_image_t img_walking;
extern bopti_image_t img_running;
extern bopti_image_t img_static;
*/
extern bopti_image_t img_circle;
static uint32_t framecounter = 0;
extern Level MyLevel;
#define SPEEDWALK 6.0f
#define SPEEDRUN 12.0f
#define SPEEDSTATIC 0.0f
#define SPEEDJUMPWALK 4.0f
#define SPEEDJUMPRUN 12.0f
#define SPEEDJUMPSTATIC 8.0f
#define MAXFALLSPEED 20.0f
Player::Player( int16_t _x, int16_t _y )
{
this->x = _x;
this->y = _y;
this->vx = 0.0f;
this->vy = 0.0f;
this->ax = 0.0f;
this->ay = 1.0f;
this->width = 8;
this->height = 8;
this->xmin = (int) this->x - this->width;
this->xmax = (int) this->x + this->width;
this->ymin = (int) this->y - this->height;
this->ymax = (int) this->y + this->height;
last_tick = rtc_ticks();
}
Player::~Player()
{
}
void Player::Update( float dt )
{
float DeltaTime = dt / 100.0f ;
//this->vx += this->ax * DeltaTime; // horizontal acceleration not considered (yet)
this->vy += this->ay * DeltaTime;
if (this->vy >= MAXFALLSPEED) this->vy = MAXFALLSPEED;
// we were jumping and are reaching the top of the curve or even starting falling
if (this->action == JUMP && this->vy >= 0)
{
this->action = FALL;
}
this->nextx = this->x + this->vx * DeltaTime;
this->nexty = this->y + this->vy * DeltaTime;
bool testdestination = MyLevel.CanGo( this ); // true if we can go to the planed position
if (testdestination)
{
this->x = this->nextx;
this->y = this->nexty;
}
else if(this->action == JUMP)
{
this->vx = 0;
this->vy = 0;
this->action = FALL;
}
else
{
this->vx = 0;
this->vy = 0;
this->action = STATIC;
}
xmin = (int) x - width;
xmax = (int) x + width;
ymin = (int) y - height;
ymax = (int) y + height;
}
void Player::Render( void )
{
uint32_t temptick = rtc_ticks();
if (temptick-last_tick>=10)
{
last_tick = temptick;
framecounter++;
}
/*
if (action==RUN)
{
uint8_t frameinternal = framecounter % 8;
azrp_subimage_p8_effect(xmin, ymin, &img_running, frameinternal*16, 0, 16, 16, direction==RIGHT ? DIMAGE_NONE : IMAGE_HFLIP );
}
else if (action==WALK)
{
uint8_t frameinternal = framecounter % 7;
azrp_subimage_p8_effect(xmin, ymin, &img_walking, frameinternal*16, 0, 16, 16, direction==RIGHT ? DIMAGE_NONE : IMAGE_HFLIP );
}
else if (action==STATIC)
{
uint8_t frameinternal = framecounter % 8;
azrp_subimage_p8_effect(xmin, ymin, &img_static, frameinternal*16, 0, 16, 16, DIMAGE_NONE);
}
*/
azrp_image_p8_effect(xmin, ymin, &img_circle, DIMAGE_NONE);
}
/*
void Player::Walk_Left( float dt )
{
if ( this->action != JUMP && this->action != FALL )
{
this->vx -= 1.0f;
if ( this->vx <= SPEEDWALK*-1.0f )
this->vx = -1.0f*SPEEDWALK;
this->direction = LEFT;
this->action = WALK;
}
this->Update( dt );
}
void Player::Walk_Right( float dt )
{
if ( this->action != JUMP && this->action != FALL )
{
this->vx += 1.0f;
if ( this->vx >= SPEEDWALK )
this->vx = SPEEDWALK;
this->direction = RIGHT;
this->action = WALK;
}
this->Update( dt );
}
*/
void Player::Run_Left( float dt )
{
if ( this->action != JUMP && this->action != FALL )
{
this->vx -= 1.0f;
if ( this->vx <= SPEEDRUN*-1.0f )
this->vx = -1.0f*SPEEDRUN;
this->direction = LEFT;
this->action = RUN;
}
this->Update( dt );
}
void Player::Run_Right( float dt )
{
if ( this->action != JUMP && this->action != FALL )
{
this->vx += 1.0f;
if ( this->vx >= SPEEDRUN )
this->vx = SPEEDRUN;
this->direction = RIGHT;
this->action = RUN;
}
this->Update( dt );
}
void Player::Jump( float dt )
{
// check if we are already jumping or not
if (this->action != JUMP && this->action != FALL) // not in a jump or in a fall
{
if ( this->action == WALK )
{
this->vy -= SPEEDJUMPWALK;
}
else if ( this->action == RUN )
{
this->vy -= SPEEDJUMPRUN;
}
else
{
this->vy -= SPEEDJUMPSTATIC;
}
}
else if ( this->action == FALL) // descending phase (FALL) of a jump, we can start a new small jump
{
this->vy -= SPEEDJUMPSTATIC;
}
else
{
}
this->action = JUMP;
this->Update( dt );
}
void Player::No_Order( float dt )
{
if (this->action == RUN || this->action == WALK)
{
this->action = BREAK;
this->vx *= 0.9;
if (ABS(this->vx) <= 0.2 )
{
this->vx = 0;
this->action = STATIC;
this->direction = STATIC;
}
}
this->Update( dt );
}

View File

@ -1,7 +1,8 @@
#include "player.h"
#include <num/num.h>
#include <gint/rtc.h>
#include "background.h"
#include "level.h"
#include "utilities.h"
/*
extern bopti_image_t img_walking;
@ -9,52 +10,91 @@ extern bopti_image_t img_running;
extern bopti_image_t img_static;
*/
extern bopti_image_t img_rectangle;
extern bopti_image_t img_circle;
static uint32_t framecounter = 0;
extern Background MyBackground;
extern Level MyLevel;
#define SPEEDWALK 6.0f
#define SPEEDRUN 12.0f
#define SPEEDSTATIC 0.0f
#define SPEEDJUMPWALK 3.0f
#define SPEEDJUMPRUN 9.0f
#define SPEEDJUMPSTATIC 6.0f
#define MAXFALLSPEED 15.0f
Player::Player( int16_t _x, int16_t _y )
{
x = libnum::num(_x);
y = libnum::num(_y);
this->x = _x;
this->y = _y;
width = 8;
height = 8;
speed = 10;
this->vx = 0.0f;
this->vy = 0.0f;
xmin = (int) x - width;
xmax = (int) x + width;
ymin = (int) y - height;
ymax = (int) y + height;
this->ax = 0.0f;
this->ay = 1.0f;
this->width = 8;
this->height = 8;
this->xmin = (int) this->x - this->width;
this->xmax = (int) this->x + this->width;
this->ymin = (int) this->y - this->height;
this->ymax = (int) this->y + this->height;
last_tick = rtc_ticks();
this->action = STATIC;
this->direction = STATIC;
}
Player::~Player()
{
}
void Player::Update( float dt, libnum::num ax, libnum::num ay )
{
libnum::num DeltaTime = libnum::num( dt / 60000.0f );
vx += ax * DeltaTime;
vy += ay * DeltaTime;
libnum::num xtemp = x + vx * DeltaTime;
libnum::num ytemp = y + vy * DeltaTime;
if (MyBackground.CanGo( this ))
void Player::Update( float dt )
{
float DeltaTime = dt / 100.0f ;
this->vy += this->ay * DeltaTime;
if (this->vy >= MAXFALLSPEED) this->vy = MAXFALLSPEED;
// we were jumping and are reaching the top of the curve or even starting falling
if (this->action == JUMP && this->vy >= 0)
{
x = xtemp;
y = ytemp;
this->action = FALL;
}
this->nextx = this->x + this->vx * DeltaTime;
this->nexty = this->y + this->vy * DeltaTime;
bool testdestination = MyLevel.CanGo( this ); // true if we can go to the planed position
if (testdestination)
{
this->x = this->nextx;
this->y = this->nexty;
}
else if(this->action == JUMP)
{
this->vx = 0;
this->vy = 0;
this->action = FALL;
}
else
{
this->vx = 0;
this->vy = 0;
this->action = STATIC;
}
xmin = (int) x - width;
xmax = (int) x + width;
ymin = (int) y - height;
@ -62,6 +102,7 @@ void Player::Update( float dt, libnum::num ax, libnum::num ay )
}
void Player::Render( void )
{
uint32_t temptick = rtc_ticks();
@ -70,105 +111,105 @@ void Player::Render( void )
last_tick = temptick;
framecounter++;
}
/*
if (action==RUN)
{
uint8_t frameinternal = framecounter % 8;
azrp_subimage_p8_effect(xmin, ymin, &img_running, frameinternal*16, 0, 16, 16, direction==RIGHT ? DIMAGE_NONE : IMAGE_HFLIP );
}
else if (action==WALK)
{
uint8_t frameinternal = framecounter % 7;
azrp_subimage_p8_effect(xmin, ymin, &img_walking, frameinternal*16, 0, 16, 16, direction==RIGHT ? DIMAGE_NONE : IMAGE_HFLIP );
}
else if (action==STATIC)
{
uint8_t frameinternal = framecounter % 8;
azrp_subimage_p8_effect(xmin, ymin, &img_static, frameinternal*16, 0, 16, 16, DIMAGE_NONE);
}
*/
azrp_image_p8_effect(xmin, ymin, &img_rectangle, DIMAGE_NONE);
}
void Player::Set_Speed( uint8_t _sp )
{
speed = _sp;
}
void Player::Walk_Left( float dt )
{
libnum::num a = libnum::num( dt / 60000.0f );
azrp_image_p8_effect(xmin, ymin, &img_circle, DIMAGE_NONE);
x -= a * libnum::num( speed/3 );
this->direction = LEFT;
this->action = WALK;
}
void Player::Walk_Right( float dt )
{
libnum::num a = libnum::num( dt / 60000.0f );
if (this->action==STATIC) Azur_draw_text( this->xmin+4, this->ymin+4, "S" );
else if (this->action==DRAFT) Azur_draw_text( this->xmin+4, this->ymin+4, "D" );
else if (this->action==WALK) Azur_draw_text( this->xmin+4, this->ymin+4, "W" );
else if (this->action==RUN) Azur_draw_text( this->xmin+4, this->ymin+4, "R" );
else if (this->action==JUMP) Azur_draw_text( this->xmin+4, this->ymin+4, "J" );
else if (this->action==FALL) Azur_draw_text( this->xmin+4, this->ymin+4, "F" );
else Azur_draw_text( this->xmin+4, this->ymin+4, "X" );
x += a * libnum::num( speed/3 );
this->direction = RIGHT;
this->action = WALK;
}
void Player::Run_Left( float dt )
{
libnum::num a = libnum::num( dt / 60000.0f );
x -= a * libnum::num( speed );
if ( this->action == STATIC )
{
this->vx -= 1.0f;
this->action = RUN;
if ( this->vx <= -SPEEDRUN ) this->vx = -SPEEDRUN;
}
else if ( this->action == JUMP || this->action == FALL )
{
this->vx -= 1.0f;
if ( this->vx <= -SPEEDRUN ) this->vx = -SPEEDRUN;
}
else if ( this->action == RUN || this->action == WALK )
{
this->vx -= 1.0f;
this->action = RUN;
if ( this->vx <= -SPEEDRUN ) this->vx = -SPEEDRUN;
}
this->direction = LEFT;
this->action = RUN;
}
void Player::Run_Right( float dt )
{
libnum::num a = libnum::num( dt / 60000.0f );
x += a * libnum::num( speed );
if ( this->action == STATIC )
{
this->vx += 1.0f;
this->action = RUN;
if ( this->vx >= SPEEDRUN ) this->vx = SPEEDRUN;
}
else if ( this->action == JUMP || this->action == FALL )
{
this->vx += 1.0f;
if ( this->vx >= SPEEDRUN ) this->vx = SPEEDRUN;
}
else if ( this->action == RUN || this->action == WALK )
{
this->vx += 1.0f;
this->action = RUN;
if ( this->vx >= SPEEDRUN ) this->vx = SPEEDRUN;
}
this->direction = RIGHT;
this->action = RUN;
}
void Player::Jump( float dt )
{
if (this->action==WALK)
if ( this->action == STATIC )
{
//this->vx = speed / 3;
this->vy = -speed / 2;
this->vy = -SPEEDJUMPSTATIC;
}
else if (this->action==RUN)
else if (this->action != JUMP && this->action != FALL) // not in a jump or in a fall
{
//this->vx = speed;
this->vy = -speed;
this->vy -= SPEEDJUMPRUN;
}
else
else if ( this->action == FALL) // descending phase (FALL) of a jump, we can start a new small jump
{
//this->vx = 0;
this->vy = -speed /2;
this->vy -= SPEEDJUMPSTATIC;
}
else if ( this->action == JUMP) // descending phase (FALL) of a jump, we can start a new small jump
{
this->vy *= 0.9f;
}
this->direction = LEFT;
this->action = JUMP;
if (this->direction==LEFT)
{
this->vx = -this->vx;
}
}
void Player::No_Order( float dt )
{
if (this->action == RUN || this->action == WALK)
{
this->action == BREAK;
}
this->action = DRAFT;
this->vx *= 0.9;
if (ABS(this->vx) <= 0.1 && ABS(this->vy) <= 0.1)
{
this->vx = 0;
this->action = STATIC;
this->direction = STATIC;
}
}
}

View File

@ -11,16 +11,20 @@
enum
{
LEFT = -2,
RIGHT = -1,
STATIC = 0,
BREAK = 1,
DRAFT = 1,
WALK = 2,
RUN = 3,
JUMP = 4,
FALL = 5,
};
enum
{
LEFT = -1,
CENTER = 0,
RIGHT = 1,
};
class Player
@ -29,11 +33,11 @@ class Player
Player( int16_t _x, int16_t _y );
~Player();
void Update( float dt, libnum::num ax, libnum::num ay );
void Update( float dt );
void Render( );
void Walk_Left( float dt );
void Walk_Right( float dt );
//void Walk_Left( float dt );
//void Walk_Right( float dt );
void Run_Left( float dt );
void Run_Right( float dt );
@ -42,23 +46,19 @@ class Player
void Jump( float dt );
void Go_Up( int action, float dt );
void Go_Down( int action, float dt );
void Set_Speed( uint8_t _sp );
libnum::num x, y; // center position of the player
libnum::num vx, vy; // speed of the player as per x and y coordinates
float x, y; // center position of the player
float nextx, nexty; // interim x and y position (to be tested to check if they can be actually achieved or not while moving)
float vx, vy; // speed of the player as per x and y coordinates
float ax, ay; // acceleration of the player as per x an y coordinates
uint8_t width, height; // width and height - for the hitbox
int16_t xmin, xmax, ymin, ymax; // square hitbox (to speed up the impact calculations)
int16_t life;
uint8_t speed; // speed of the player
uint32_t last_tick;
bool playeronground = true;
int8_t direction = STATIC;
int8_t action = STATIC;
};

View File

@ -3,4 +3,6 @@
void Azur_draw_text(int x, int y, char const *fmt, ...);
#define ABS(a) ( ( (a) >= 0 ) ? (a) : -(a) )
#endif