WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Examples
  4. cubeapp.rs
Mission NodeSDK 6.3RustbasicsProject Included

cubeapp.rs

Example: cubeapp.rs

Examples / SDK 6.3 / Rust / basics / Working with Emulator / project / src
cubeapp.rs
RUST
1// This file is generated by WOWCube SDK project wizard
2//
3// Application UUID: UIvZXEq-Hw
4//
5
6use wowcube_sdk::application::{
7 AppErr, Application, ApplicationContext, Mappable, TimerController,
8};
9
10use wowcube_sdk::cubios;
11use wowcube_sdk::cubios::{comm, gfx, topology};
12
13const TEXT_SIZE: u32 = 10;
14const TIMER_ID_ONE: u8 = 1;
15
16#[derive(Default)]
17pub struct WorkingWIthEmulator {
18 initialized: bool,
19 app_context: ApplicationContext,
20 fps: f32,
21 seconds: u32,
22}
23
24impl WorkingWIthEmulator {
25 pub fn new() -> Self {
26 WorkingWIthEmulator::default()
27 }
28
29 pub fn initialize_resources(&mut self) {
30 comm::log_i("\n");
31 comm::log_i("*** WOWCube SDK Example \"Working with Emulator\" ***\n");
32 comm::log_i("Cubeapp is initializing...");
33 comm::log_i("Cubeapp is started");
34
35 self.set_timer(TIMER_ID_ONE, 1000, false);
36 }
37}
38
39impl Mappable for WorkingWIthEmulator {}
40
41impl Application for WorkingWIthEmulator {
42 fn app_context_mut(&mut self) -> &mut ApplicationContext {
43 &mut self.app_context
44 }
45
46 fn on_render(&self) -> Result<(), AppErr> {
47 if !self.initialized {
48 return Ok(());
49 }
50
51 for screen in 0..3 {
52 gfx::set_render_target(screen as u8);
53
54 gfx::clear(0xff000000);
55
56 gfx::draw_text(
57 120,
58 80,
59 TEXT_SIZE,
60 0,
61 cubios::TextAlign::Center,
62 0xffffffff as u32,
63 "CHECK",
64 );
65 gfx::draw_text(
66 120,
67 120,
68 TEXT_SIZE,
69 0,
70 cubios::TextAlign::Center,
71 0xffffffff as u32,
72 "THE",
73 );
74 gfx::draw_text(
75 120,
76 160,
77 TEXT_SIZE,
78 0,
79 cubios::TextAlign::Center,
80 0xffffffff as u32,
81 "CONSOLE",
82 );
83
84 gfx::render();
85 }
86
87 Ok(())
88 }
89
90 fn on_init(&mut self) -> Result<(), AppErr> {
91 self.initialized = true;
92
93 Ok(())
94 }
95
96 fn on_tick(&mut self) -> Result<(), AppErr> {
97 if !self.initialized {
98 self.on_init()?;
99 }
100
101 let delta_time = self.app_context.timer_controller.delta_time();
102 if delta_time > 0 {
103 self.fps = 1000.0 / delta_time as f32;
104 } else {
105 self.fps = 0.0;
106 }
107
108 comm::log_i(&format!(" Seconds passed: {:} s", self.seconds));
109 comm::log_i(&format!(" Current fps: {:.2}", self.fps));
110 comm::log_i(&format!(
111 " Delta time: {:} ms",
112 self.app_context.timer_controller.delta_time()
113 ));
114
115 Ok(())
116 }
117
118 fn on_timer(&mut self, timer_id: u8) -> Result<(), AppErr> {
119 match timer_id {
120 TIMER_ID_ONE => {
121 self.seconds += 1;
122 if self.seconds > 99 {
123 self.seconds = 0;
124 }
125 }
126 _ => {
127 println!("Unknown timer ID!");
128 }
129 }
130 Ok(())
131 }
132}
133
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Project files

This section gets modified automatically to match the settings of your project
project/Cargo.toml
cubeapp.rs
project/src/cubeapp.rs
main.rs
project/src/main.rs
wowcubeapp-build.json
project/wowcubeapp-build.json
Context Rail

Related nodes

main.rs
Examples / SDK 6.3 / Rust / basics / Working with Emulator / project / src
Working with Emulator
Examples / SDK 6.3 / Rust / basics
info.json
Examples / SDK 6.3 / Rust / basics / Working with Emulator
This section gets modified automatically to match the settings of your project
Examples / SDK 6.3 / Rust / basics / Working with Emulator / project
Previous Node
This section gets modified automatically to match the settings of your project
Examples / SDK 6.3 / Rust / basics / Working with Emulator / project
Next Node
main.rs
Examples / SDK 6.3 / Rust / basics / Working with Emulator / project / src