working on player movements
parent
afe112230b
commit
a174837a53
|
@ -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
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":14,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[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, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.8.0",
|
||||
"tileheight":16,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"tilesetnpp.tsx"
|
||||
}],
|
||||
"tilewidth":16,
|
||||
"type":"map",
|
||||
"version":"1.8",
|
||||
"width":25
|
||||
}
|
|
@ -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">
|
||||
|
@ -23,17 +23,17 @@
|
|||
<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,31,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,44,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,44,0,
|
||||
0,44,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,44,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,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,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,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,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
|
||||
</data>
|
||||
</layer>
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":14,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[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, 2, 2, 3, 0, 0, 0, 0, 4, 2, 2, 2, 2, 2, 2,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 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,
|
||||
"width":25,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":4,
|
||||
"nextobjectid":3,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.8.0",
|
||||
"tileheight":16,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"tilesetnpp.tsx"
|
||||
}],
|
||||
"tilewidth":16,
|
||||
"type":"map",
|
||||
"version":"1.8",
|
||||
"width":25
|
||||
}
|
|
@ -6,33 +6,33 @@
|
|||
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,
|
||||
2,2,3,0,0,0,0,4,2,2,2,2,2,2,2,2,2,3,0,0,0,0,4,2,2,
|
||||
2,3,0,0,0,0,0,0,4,2,5,6,0,7,8,2,3,0,0,0,0,0,0,4,2,
|
||||
2,0,0,20,2,2,19,0,0,0,0,0,0,0,0,0,0,0,20,2,2,19,0,0,2,
|
||||
2,0,0,14,2,2,13,0,0,0,0,0,0,0,0,0,0,0,14,2,2,13,0,0,2,
|
||||
2,0,0,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0,2,
|
||||
2,0,0,2,2,2,2,0,0,0,23,24,2,21,22,0,0,0,2,2,2,2,0,0,2,
|
||||
2,0,0,2,2,2,2,0,0,0,17,18,2,15,16,0,0,0,2,2,2,2,0,0,2,
|
||||
2,1,0,2,2,2,2,0,0,0,2,2,2,2,2,0,0,0,2,2,2,2,0,0,2,
|
||||
2,0,0,2,2,2,2,0,0,0,2,3,1,4,2,0,0,0,2,2,2,2,0,0,2,
|
||||
2,0,0,2,2,2,2,19,0,20,2,1,0,1,2,19,0,20,2,2,2,2,0,0,2,
|
||||
2,0,0,2,2,2,2,13,0,14,2,1,0,1,2,13,0,14,2,2,2,2,0,0,2,
|
||||
2,0,0,2,2,2,2,2,2,2,2,1,2,1,2,2,2,2,2,2,2,2,0,0,2,
|
||||
2,0,0,4,2,2,2,2,2,5,6,1,2,1,7,8,2,2,2,2,2,3,0,0,2,
|
||||
2,19,0,0,33,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,33,0,0,20,2,
|
||||
2,2,19,0,33,0,0,1,0,0,23,24,2,21,22,1,0,0,0,0,33,0,20,2,2,
|
||||
2,13,0,0,22,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,14,2,
|
||||
2,2,13,0,22,0,0,1,0,0,17,18,2,15,16,1,0,0,0,0,21,1,14,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,2,2
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Foreground" width="25" height="14">
|
||||
<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,36,36,0,0,0,0,0,0,0,0,0,0,0,0,0,36,36,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,67,0,0,0,0,0,67,0,0,0,0,0,0,0,0,0,
|
||||
0,0,66,0,0,0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,66,0,0,
|
||||
0,35,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,52,0,0,0,0,0,35,0,0,0,0,0,0,66,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,51,0,0,0,11,0,0,0,51,0,0,0,0,0,66,0,0,
|
||||
0,35,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,43,0,0,0,0,0,0,0,0,0,
|
||||
0,0,42,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,42,0,0,
|
||||
0,23,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,34,0,
|
||||
0,0,42,0,0,0,0,0,0,34,0,0,0,0,0,23,0,0,0,0,0,0,42,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,33,0,0,0,32,0,0,1,33,0,0,0,0,0,42,0,0,
|
||||
0,23,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,34,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,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>
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
{ "compressionlevel":-1,
|
||||
"height":14,
|
||||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 1, 1, 1, 23, 24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 1, 1, 1],
|
||||
"height":14,
|
||||
"id":1,
|
||||
"name":"Background",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"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, 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],
|
||||
"height":14,
|
||||
"id":2,
|
||||
"name":"Foreground",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":25,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":3,
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.8.0",
|
||||
"tileheight":16,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"source":"tilesetnpp.tsx"
|
||||
}],
|
||||
"tilewidth":16,
|
||||
"type":"map",
|
||||
"version":"1.8",
|
||||
"width":25
|
||||
}
|
|
@ -3,19 +3,19 @@
|
|||
<tileset firstgid="1" source="tilesetnpp.tsx"/>
|
||||
<layer id="1" name="Background" width="25" height="14">
|
||||
<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,17,18,2,2,15,16,1,1,1,1,1,17,18,2,2,15,16,1,1,1,1,
|
||||
1,1,1,14,5,6,22,1,7,8,15,16,1,17,18,5,6,22,0,7,8,13,1,1,1,
|
||||
1,1,14,3,0,0,22,1,0,0,4,2,2,2,3,0,0,22,0,0,0,4,13,1,1,
|
||||
1,14,3,0,0,0,22,1,0,0,0,10,2,9,0,0,0,22,0,0,0,0,4,13,1,
|
||||
30,9,0,0,0,0,2,2,0,0,0,20,2,19,0,0,0,2,2,1,0,0,1,10,29,
|
||||
40,19,0,0,17,18,2,2,29,0,0,0,2,0,0,0,30,2,2,15,16,0,0,20,39,
|
||||
2,0,0,14,2,2,2,2,39,0,0,0,0,0,0,0,40,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,
|
||||
10,29,0,0,7,8,2,2,2,2,2,2,2,2,2,2,2,2,2,5,6,0,0,30,9,
|
||||
20,39,0,0,0,0,4,2,5,6,0,0,0,0,0,7,8,2,3,0,0,0,0,40,19,
|
||||
1,4,13,0,0,0,0,21,0,0,0,14,2,13,0,0,0,21,0,0,0,0,14,3,1,
|
||||
1,1,4,13,0,0,0,21,0,0,14,2,2,2,13,0,0,21,0,0,0,14,3,1,1,
|
||||
1,1,1,4,15,16,0,21,17,18,5,6,1,7,8,15,16,21,0,17,18,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,42,0,0,0,42,0,28,0,0,0,0,42,0,36,37,
|
||||
0,0,42,0,0,0,0,0,37,0,0,0,0,0,0,0,38,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,
|
||||
26,27,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,0,28,25,
|
||||
36,37,0,0,42,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,42,0,0,38,35,
|
||||
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 |
|
@ -1,14 +0,0 @@
|
|||
{ "columns":16,
|
||||
"image":"tileset.png",
|
||||
"imageheight":256,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"tileset",
|
||||
"spacing":0,
|
||||
"tilecount":256,
|
||||
"tiledversion":"1.8.0",
|
||||
"tileheight":16,
|
||||
"tilewidth":16,
|
||||
"type":"tileset",
|
||||
"version":"1.8"
|
||||
}
|
|
@ -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 |
|
@ -0,0 +1,3 @@
|
|||
rm -r build-cg
|
||||
rm *.g3a
|
||||
fxsdk build-cg-push -s VERBOSE=1
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
#include "level.h"
|
||||
#include "player.h"
|
||||
#include <azur/azur.h>
|
||||
#include <azur/gint/render.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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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::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 % map_level->w;
|
||||
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;
|
||||
}
|
|
@ -25,19 +25,24 @@ 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 );
|
||||
};
|
||||
|
||||
|
52
src/main.cpp
52
src/main.cpp
|
@ -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=2;
|
||||
|
||||
|
||||
#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,25 @@ 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,01, "FPS = %.0f", (float) (1000.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>=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,23 +130,23 @@ 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); }
|
||||
// if( MyKeyboard.IsKeyPressedEvent(MYKEY_F4) ) { MyLevel.ChangeMap(4, &MyPlayer); }
|
||||
// if( MyKeyboard.IsKeyPressedEvent(MYKEY_F5) ) { MyLevel.ChangeMap(5, &MyPlayer); }
|
||||
// if( MyKeyboard.IsKeyPressedEvent(MYKEY_F6) ) { MyLevel.ChangeMap(6, &MyPlayer); }
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -170,7 +171,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 +257,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
|
||||
|
@ -269,7 +273,7 @@ int main(void)
|
|||
|
||||
get_inputs( elapsedTime );
|
||||
|
||||
update( elapsedTime );
|
||||
// update( elapsedTime );
|
||||
|
||||
// update the RAM consumption status
|
||||
_uram_stats = kmalloc_get_gint_stats(_uram);
|
||||
|
@ -292,7 +296,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);
|
||||
|
|
187
src/player.cpp
187
src/player.cpp
|
@ -1,7 +1,7 @@
|
|||
#include "player.h"
|
||||
#include <num/num.h>
|
||||
#include <gint/rtc.h>
|
||||
#include "background.h"
|
||||
#include "level.h"
|
||||
|
||||
/*
|
||||
extern bopti_image_t img_walking;
|
||||
|
@ -9,27 +9,41 @@ 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 4.0f
|
||||
#define SPEEDJUMPRUN 12.0f
|
||||
#define SPEEDJUMPSTATIC 8.0f
|
||||
|
||||
#define MAXFALLSPEED 20.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();
|
||||
}
|
||||
|
@ -40,21 +54,48 @@ 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->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)
|
||||
{
|
||||
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;
|
||||
|
@ -88,87 +129,111 @@ void Player::Render( void )
|
|||
}
|
||||
*/
|
||||
|
||||
azrp_image_p8_effect(xmin, ymin, &img_rectangle, DIMAGE_NONE);
|
||||
azrp_image_p8_effect(xmin, ymin, &img_circle, 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 );
|
||||
|
||||
x -= a * libnum::num( speed/3 );
|
||||
{
|
||||
this->vx = SPEEDWALK * -1.0f;
|
||||
|
||||
this->direction = LEFT;
|
||||
this->action = WALK;
|
||||
|
||||
this->Update( dt );
|
||||
}
|
||||
|
||||
void Player::Walk_Right( float dt )
|
||||
{
|
||||
libnum::num a = libnum::num( dt / 60000.0f );
|
||||
|
||||
x += a * libnum::num( speed/3 );
|
||||
|
||||
this->vx = SPEEDWALK * 1.0f;
|
||||
this->direction = RIGHT;
|
||||
this->action = WALK;
|
||||
|
||||
this->Update( dt );
|
||||
}
|
||||
|
||||
void Player::Run_Left( float dt )
|
||||
{
|
||||
libnum::num a = libnum::num( dt / 60000.0f );
|
||||
|
||||
x -= a * libnum::num( speed );
|
||||
|
||||
this->vx = SPEEDRUN * -1.0f;
|
||||
this->direction = LEFT;
|
||||
this->action = RUN;
|
||||
|
||||
this->Update( dt );
|
||||
}
|
||||
|
||||
void Player::Run_Right( float dt )
|
||||
{
|
||||
libnum::num a = libnum::num( dt / 60000.0f );
|
||||
|
||||
x += a * libnum::num( speed );
|
||||
this->vx = SPEEDRUN * 1.0f;
|
||||
|
||||
this->direction = RIGHT;
|
||||
this->action = RUN;
|
||||
|
||||
this->Update( dt );
|
||||
}
|
||||
|
||||
void Player::Jump( float dt )
|
||||
{
|
||||
if (this->action==WALK)
|
||||
// check if we are already jumping or not
|
||||
if (this->action != JUMP && this->action != FALL) // not in a jump or in a fall
|
||||
{
|
||||
//this->vx = speed / 3;
|
||||
this->vy = -speed / 2;
|
||||
if (this->action==WALK)
|
||||
{
|
||||
this->vy = SPEEDJUMPWALK * -1.0f;
|
||||
}
|
||||
else if (this->action==RUN)
|
||||
{
|
||||
this->vy = SPEEDJUMPRUN * -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->vy = SPEEDJUMPSTATIC * -1.0f;
|
||||
}
|
||||
}
|
||||
else if (this->action==RUN)
|
||||
else if (this->action == FALL) // descending phase (FALL) of a jump, we can start a new small jump
|
||||
{
|
||||
//this->vx = speed;
|
||||
this->vy = -speed;
|
||||
this->vy = SPEEDJUMPSTATIC * -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//this->vx = 0;
|
||||
this->vy = -speed /2;
|
||||
|
||||
}
|
||||
|
||||
this->direction = LEFT;
|
||||
this->action = JUMP;
|
||||
|
||||
if (this->direction==LEFT)
|
||||
{
|
||||
this->vx = -this->vx;
|
||||
}
|
||||
this->Update( dt );
|
||||
}
|
||||
|
||||
void Player::No_Order( float dt )
|
||||
{
|
||||
/*
|
||||
if (this->action == RUN || this->action == WALK)
|
||||
{
|
||||
this->action == BREAK;
|
||||
}
|
||||
this->action = BREAK;
|
||||
}
|
||||
|
||||
if (this->direction == LEFT) // we were going LEFT and we stop moving to the left so we decrease speed till reaching static
|
||||
{
|
||||
this->vx += 1;
|
||||
if (vx>=0)
|
||||
{
|
||||
this->vx = 0;
|
||||
this->action = STATIC;
|
||||
this->direction = STATIC;
|
||||
}
|
||||
}
|
||||
else if (this->direction == RIGHT) // we were going RIGHT and we stop moving to the left so we decrease speed till reaching static
|
||||
{
|
||||
this->vx -= 1;
|
||||
if (vx<=0)
|
||||
{
|
||||
this->vx = 0;
|
||||
this->action = STATIC;
|
||||
this->direction = STATIC;
|
||||
}
|
||||
}
|
||||
|
||||
this->Update( 0.0f, 0.0, 0.0 );
|
||||
*/
|
||||
|
||||
this->Update( dt );
|
||||
}
|
||||
|
|
16
src/player.h
16
src/player.h
|
@ -29,7 +29,7 @@ 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 );
|
||||
|
@ -42,21 +42,15 @@ 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;
|
||||
|
||||
int8_t direction = STATIC;
|
||||
|
|
Loading…
Reference in New Issue