updated
This commit is contained in:
parent
cca197bf45
commit
36cb36ffee
9 changed files with 126 additions and 1 deletions
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
//Include the Arduboy Library
|
//Include the Arduboy Library
|
||||||
//Initialize the arduboy object
|
//Initialize the arduboy object
|
||||||
|
|
||||||
use arduboy_rust::prelude::*;
|
use arduboy_rust::prelude::*;
|
||||||
use fx_consts::{dbmMasked, dbmNormal};
|
use fx_consts::{dbmMasked, dbmNormal};
|
||||||
|
|
||||||
const arduboy: Arduboy2 = Arduboy2::new();
|
const arduboy: Arduboy2 = Arduboy2::new();
|
||||||
|
|
||||||
// FX Data
|
// FX Data
|
||||||
|
|
13
Project/test_game/Cargo.toml
Normal file
13
Project/test_game/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "test_game"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["staticlib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
[dependencies.arduboy-rust]
|
||||||
|
path = "../../arduboy-rust"
|
BIN
Project/test_game/assets/player_8x8.png
Normal file
BIN
Project/test_game/assets/player_8x8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 302 B |
9
Project/test_game/config.toml
Normal file
9
Project/test_game/config.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Libraries = [
|
||||||
|
"Arduboy2",
|
||||||
|
#"ArduboyTones",
|
||||||
|
"ArduboyFX",
|
||||||
|
#"ArdVoice",
|
||||||
|
#"Serial",
|
||||||
|
"EEPROM",
|
||||||
|
"Arduino",
|
||||||
|
]
|
BIN
Project/test_game/fxdata/fxdata-data.bin
Normal file
BIN
Project/test_game/fxdata/fxdata-data.bin
Normal file
Binary file not shown.
BIN
Project/test_game/fxdata/fxdata.bin
Normal file
BIN
Project/test_game/fxdata/fxdata.bin
Normal file
Binary file not shown.
16
Project/test_game/fxdata/fxdata.h
Normal file
16
Project/test_game/fxdata/fxdata.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**** FX data header generated by fxdata-build.py tool version 1.15 ****/
|
||||||
|
|
||||||
|
using uint24_t = __uint24;
|
||||||
|
|
||||||
|
// Initialize FX hardware using FX::begin(FX_DATA_PAGE); in the setup() function.
|
||||||
|
|
||||||
|
constexpr uint16_t FX_DATA_PAGE = 0xffff;
|
||||||
|
constexpr uint24_t FX_DATA_BYTES = 124;
|
||||||
|
|
||||||
|
constexpr uint24_t FX_DATA_TILES = 0x000000;
|
||||||
|
constexpr uint16_t FX_DATA_TILES_WIDTH = 8;
|
||||||
|
constexpr uint16_t FX_DATA_TILESHEIGHT = 8;
|
||||||
|
constexpr uint8_t FX_DATA_TILES_FRAMES = 15;
|
||||||
|
|
1
Project/test_game/fxdata/fxdata.txt
Normal file
1
Project/test_game/fxdata/fxdata.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
image_t FX_DATA_TILES = "../assets/player_8x8.png"
|
86
Project/test_game/src/lib.rs
Normal file
86
Project/test_game/src/lib.rs
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#![no_std]
|
||||||
|
#![allow(non_upper_case_globals)]
|
||||||
|
|
||||||
|
//Include the Arduboy Library
|
||||||
|
|
||||||
|
use arduboy_rust::prelude::*;
|
||||||
|
|
||||||
|
extern crate arduboy_rust;
|
||||||
|
use fx_consts::*;
|
||||||
|
|
||||||
|
const FX_DATA_PAGE: u16 = 0xffff;
|
||||||
|
const FX_DATA_BYTES: u32 = 244;
|
||||||
|
const FX_DATA_TILES: u32 = 0x000000;
|
||||||
|
const FX_DATA_TILES_WIDTH: u16 = 8;
|
||||||
|
const FX_DATA_TILESHEIGHT: u16 = 8;
|
||||||
|
const FX_DATA_TILES_FRAMES: u8 = 15;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
const arduboy: Arduboy2 = Arduboy2::new();
|
||||||
|
|
||||||
|
// Progmem data
|
||||||
|
|
||||||
|
// dynamic ram variables
|
||||||
|
static mut lol: u8 = 0;
|
||||||
|
enum State {
|
||||||
|
Run,
|
||||||
|
Idle1,
|
||||||
|
Idle2,
|
||||||
|
Hurt,
|
||||||
|
Death,
|
||||||
|
}
|
||||||
|
impl State {
|
||||||
|
fn get_frames(&self) -> (u8, u8) {
|
||||||
|
match self {
|
||||||
|
State::Run => (0, 3),
|
||||||
|
State::Idle1 => (4, 5),
|
||||||
|
State::Idle2 => (6, 7),
|
||||||
|
State::Hurt => (8, 10),
|
||||||
|
State::Death => (11, 14),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn next_state(&mut self) {
|
||||||
|
match self {
|
||||||
|
State::Run => *self = State::Idle1,
|
||||||
|
State::Idle1 => *self = State::Idle2,
|
||||||
|
State::Idle2 => *self = State::Hurt,
|
||||||
|
State::Hurt => *self = State::Death,
|
||||||
|
State::Death => *self = State::Run,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static mut state: State = State::Run;
|
||||||
|
// The setup() function runs once when you turn your Arduboy on
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
arduboy.begin();
|
||||||
|
fx::begin_data(FX_DATA_PAGE);
|
||||||
|
arduboy.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
// The loop() function repeats forever after setup() is done
|
||||||
|
#[no_mangle]
|
||||||
|
#[export_name = "loop"]
|
||||||
|
pub unsafe extern "C" fn loop_() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
if !arduboy.next_frame() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
arduboy.poll_buttons();
|
||||||
|
if A.just_pressed() {
|
||||||
|
state.next_state();
|
||||||
|
}
|
||||||
|
let (min, max) = state.get_frames();
|
||||||
|
if arduboy.every_x_frames(10) {
|
||||||
|
lol += 1;
|
||||||
|
if lol < min {
|
||||||
|
lol = min;
|
||||||
|
}
|
||||||
|
if lol > max {
|
||||||
|
lol = min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fx::draw_bitmap(0, 0, FX_DATA_TILES, lol, dbmNormal);
|
||||||
|
fx::display_clear()
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue