hello_world/
hello_world.rs

1#![no_std]
2
3#[macro_use]
4extern crate playdate_rs;
5
6use playdate_rs::graphics::{Bitmap, Color};
7use playdate_rs::{app, println, App, PLAYDATE};
8
9#[app]
10pub struct HelloWorld {
11    image: Bitmap,
12    rotation: f32,
13}
14
15impl App for HelloWorld {
16    fn new() -> Self {
17        println!("Hello, World!");
18        Self {
19            image: PLAYDATE.graphics.load_bitmap("rust").unwrap(),
20            rotation: 0f32,
21        }
22    }
23
24    fn update(&mut self, delta: f32) {
25        // Clear screen
26        PLAYDATE.graphics.clear(Color::White);
27        // Draw image
28        PLAYDATE.graphics.draw_rotated_bitmap(
29            &self.image,
30            vec2![130, 120],
31            self.rotation,
32            vec2![0.5, 0.5],
33            vec2![1.0, 1.0],
34        );
35        // Rotate image
36        self.rotation += delta * 90.0;
37        // Draw text
38        PLAYDATE
39            .graphics
40            .draw_text("Hello, World!", vec2![230, 112]);
41        // Draw FPS
42        PLAYDATE.system.draw_fps(vec2![0, 0]);
43    }
44}