+293
-5
Cargo.lock
+293
-5
Cargo.lock
···
7
7
version = "0.1.0"
8
8
dependencies = [
9
9
"agb",
10
+
"agb_tracker",
10
11
]
11
12
12
13
[[package]]
···
67
68
"proc-macro2",
68
69
"quote",
69
70
"snafu",
70
-
"syn",
71
+
"syn 2.0.106",
71
72
]
72
73
73
74
[[package]]
···
78
79
dependencies = [
79
80
"proc-macro2",
80
81
"quote",
81
-
"syn",
82
+
"syn 2.0.106",
83
+
]
84
+
85
+
[[package]]
86
+
name = "agb_midi"
87
+
version = "0.22.5"
88
+
source = "registry+https://github.com/rust-lang/crates.io-index"
89
+
checksum = "fbb85c5aa883e12140b654de074bfc46e82398b6b1c98284cfc10341b72235ca"
90
+
dependencies = [
91
+
"agb_midi_core",
92
+
"agb_tracker_interop",
93
+
"midly",
94
+
"proc-macro-error",
95
+
"proc-macro2",
96
+
"quote",
97
+
"rustysynth",
98
+
"syn 2.0.106",
99
+
]
100
+
101
+
[[package]]
102
+
name = "agb_midi_core"
103
+
version = "0.22.5"
104
+
source = "registry+https://github.com/rust-lang/crates.io-index"
105
+
checksum = "f7f3ed57eacc49f14df5e426a7158045f798fea58e20d5b5504c6c136ad8f420"
106
+
dependencies = [
107
+
"agb_fixnum",
108
+
"agb_tracker_interop",
109
+
"midly",
110
+
"rustysynth",
82
111
]
83
112
84
113
[[package]]
···
90
119
"hound",
91
120
"proc-macro2",
92
121
"quote",
93
-
"syn",
122
+
"syn 2.0.106",
123
+
]
124
+
125
+
[[package]]
126
+
name = "agb_tracker"
127
+
version = "0.22.5"
128
+
source = "registry+https://github.com/rust-lang/crates.io-index"
129
+
checksum = "a3b0863b14d11864a9eb2f212c4fd666de014975d8ea349bd86038b5faf52ab8"
130
+
dependencies = [
131
+
"agb",
132
+
"agb_fixnum",
133
+
"agb_midi",
134
+
"agb_tracker_interop",
135
+
"agb_xm",
136
+
]
137
+
138
+
[[package]]
139
+
name = "agb_tracker_interop"
140
+
version = "0.22.5"
141
+
source = "registry+https://github.com/rust-lang/crates.io-index"
142
+
checksum = "bc34242c6783033c55eeb18ac5b62ca9bbf481ba369278ce9a819b047863d473"
143
+
dependencies = [
144
+
"agb_fixnum",
145
+
"proc-macro2",
146
+
"quote",
147
+
]
148
+
149
+
[[package]]
150
+
name = "agb_xm"
151
+
version = "0.22.5"
152
+
source = "registry+https://github.com/rust-lang/crates.io-index"
153
+
checksum = "9f055bf375cd3a3aa4cbe6638c7a2856ec38c2813a281dc4f0e51af7b68ec559"
154
+
dependencies = [
155
+
"agb_tracker_interop",
156
+
"agb_xm_core",
157
+
"proc-macro-error",
158
+
"proc-macro2",
159
+
"quote",
160
+
"syn 2.0.106",
161
+
"xmrs",
162
+
]
163
+
164
+
[[package]]
165
+
name = "agb_xm_core"
166
+
version = "0.22.5"
167
+
source = "registry+https://github.com/rust-lang/crates.io-index"
168
+
checksum = "d37ed3582ceb772c679cfe96f73ef127831c60d44f51dc1c9a2325aab3649f60"
169
+
dependencies = [
170
+
"agb_fixnum",
171
+
"agb_tracker_interop",
172
+
"proc-macro-error",
173
+
"proc-macro2",
174
+
"quote",
175
+
"syn 2.0.106",
176
+
"xmrs",
94
177
]
95
178
96
179
[[package]]
···
145
228
"proc-macro-error",
146
229
"proc-macro2",
147
230
"quote",
148
-
"syn",
231
+
"syn 2.0.106",
232
+
]
233
+
234
+
[[package]]
235
+
name = "bincode"
236
+
version = "2.0.1"
237
+
source = "registry+https://github.com/rust-lang/crates.io-index"
238
+
checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740"
239
+
dependencies = [
240
+
"bincode_derive",
241
+
"serde",
242
+
"unty",
243
+
]
244
+
245
+
[[package]]
246
+
name = "bincode_derive"
247
+
version = "2.0.1"
248
+
source = "registry+https://github.com/rust-lang/crates.io-index"
249
+
checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09"
250
+
dependencies = [
251
+
"virtue",
149
252
]
150
253
151
254
[[package]]
···
289
392
]
290
393
291
394
[[package]]
395
+
name = "indexmap"
396
+
version = "2.11.4"
397
+
source = "registry+https://github.com/rust-lang/crates.io-index"
398
+
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
399
+
dependencies = [
400
+
"equivalent",
401
+
"hashbrown",
402
+
]
403
+
404
+
[[package]]
292
405
name = "itertools"
293
406
version = "0.11.0"
294
407
source = "registry+https://github.com/rust-lang/crates.io-index"
···
304
417
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
305
418
306
419
[[package]]
420
+
name = "memchr"
421
+
version = "2.7.6"
422
+
source = "registry+https://github.com/rust-lang/crates.io-index"
423
+
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
424
+
425
+
[[package]]
426
+
name = "micromath"
427
+
version = "2.1.0"
428
+
source = "registry+https://github.com/rust-lang/crates.io-index"
429
+
checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815"
430
+
431
+
[[package]]
432
+
name = "midly"
433
+
version = "0.5.3"
434
+
source = "registry+https://github.com/rust-lang/crates.io-index"
435
+
checksum = "207d755f4cb882d20c4da58d707ca9130a0c9bc5061f657a4f299b8e36362b7a"
436
+
437
+
[[package]]
307
438
name = "miniz_oxide"
308
439
version = "0.8.9"
309
440
source = "registry+https://github.com/rust-lang/crates.io-index"
···
329
460
]
330
461
331
462
[[package]]
463
+
name = "num_enum"
464
+
version = "0.7.4"
465
+
source = "registry+https://github.com/rust-lang/crates.io-index"
466
+
checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a"
467
+
dependencies = [
468
+
"num_enum_derive",
469
+
"rustversion",
470
+
]
471
+
472
+
[[package]]
473
+
name = "num_enum_derive"
474
+
version = "0.7.4"
475
+
source = "registry+https://github.com/rust-lang/crates.io-index"
476
+
checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d"
477
+
dependencies = [
478
+
"proc-macro-crate",
479
+
"proc-macro2",
480
+
"quote",
481
+
"syn 2.0.106",
482
+
]
483
+
484
+
[[package]]
332
485
name = "once_cell"
333
486
version = "1.21.3"
334
487
source = "registry+https://github.com/rust-lang/crates.io-index"
···
364
517
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
365
518
366
519
[[package]]
520
+
name = "proc-macro-crate"
521
+
version = "3.4.0"
522
+
source = "registry+https://github.com/rust-lang/crates.io-index"
523
+
checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983"
524
+
dependencies = [
525
+
"toml_edit",
526
+
]
527
+
528
+
[[package]]
367
529
name = "proc-macro-error"
368
530
version = "1.0.4"
369
531
source = "registry+https://github.com/rust-lang/crates.io-index"
···
372
534
"proc-macro-error-attr",
373
535
"proc-macro2",
374
536
"quote",
537
+
"syn 1.0.109",
375
538
"version_check",
376
539
]
377
540
···
417
580
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
418
581
419
582
[[package]]
583
+
name = "rustversion"
584
+
version = "1.0.22"
585
+
source = "registry+https://github.com/rust-lang/crates.io-index"
586
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
587
+
588
+
[[package]]
589
+
name = "rustysynth"
590
+
version = "1.3.6"
591
+
source = "registry+https://github.com/rust-lang/crates.io-index"
592
+
checksum = "e3ca93af923df5fc03beddbf464242620fd24daa9e10f9ecd56eb9571eb7ba38"
593
+
594
+
[[package]]
595
+
name = "serde"
596
+
version = "1.0.226"
597
+
source = "registry+https://github.com/rust-lang/crates.io-index"
598
+
checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
599
+
dependencies = [
600
+
"serde_core",
601
+
"serde_derive",
602
+
]
603
+
604
+
[[package]]
605
+
name = "serde-big-array"
606
+
version = "0.5.1"
607
+
source = "registry+https://github.com/rust-lang/crates.io-index"
608
+
checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
609
+
dependencies = [
610
+
"serde",
611
+
]
612
+
613
+
[[package]]
614
+
name = "serde_core"
615
+
version = "1.0.226"
616
+
source = "registry+https://github.com/rust-lang/crates.io-index"
617
+
checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
618
+
dependencies = [
619
+
"serde_derive",
620
+
]
621
+
622
+
[[package]]
623
+
name = "serde_derive"
624
+
version = "1.0.226"
625
+
source = "registry+https://github.com/rust-lang/crates.io-index"
626
+
checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
627
+
dependencies = [
628
+
"proc-macro2",
629
+
"quote",
630
+
"syn 2.0.106",
631
+
]
632
+
633
+
[[package]]
420
634
name = "simd-adler32"
421
635
version = "0.3.7"
422
636
source = "registry+https://github.com/rust-lang/crates.io-index"
···
440
654
"heck",
441
655
"proc-macro2",
442
656
"quote",
443
-
"syn",
657
+
"syn 2.0.106",
658
+
]
659
+
660
+
[[package]]
661
+
name = "syn"
662
+
version = "1.0.109"
663
+
source = "registry+https://github.com/rust-lang/crates.io-index"
664
+
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
665
+
dependencies = [
666
+
"proc-macro2",
667
+
"unicode-ident",
444
668
]
445
669
446
670
[[package]]
···
455
679
]
456
680
457
681
[[package]]
682
+
name = "toml_datetime"
683
+
version = "0.7.2"
684
+
source = "registry+https://github.com/rust-lang/crates.io-index"
685
+
checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1"
686
+
dependencies = [
687
+
"serde_core",
688
+
]
689
+
690
+
[[package]]
691
+
name = "toml_edit"
692
+
version = "0.23.6"
693
+
source = "registry+https://github.com/rust-lang/crates.io-index"
694
+
checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b"
695
+
dependencies = [
696
+
"indexmap",
697
+
"toml_datetime",
698
+
"toml_parser",
699
+
"winnow",
700
+
]
701
+
702
+
[[package]]
703
+
name = "toml_parser"
704
+
version = "1.0.3"
705
+
source = "registry+https://github.com/rust-lang/crates.io-index"
706
+
checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627"
707
+
dependencies = [
708
+
"winnow",
709
+
]
710
+
711
+
[[package]]
458
712
name = "ttf-parser"
459
713
version = "0.21.1"
460
714
source = "registry+https://github.com/rust-lang/crates.io-index"
···
467
721
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
468
722
469
723
[[package]]
724
+
name = "unty"
725
+
version = "0.0.4"
726
+
source = "registry+https://github.com/rust-lang/crates.io-index"
727
+
checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
728
+
729
+
[[package]]
470
730
name = "version_check"
471
731
version = "0.9.5"
472
732
source = "registry+https://github.com/rust-lang/crates.io-index"
473
733
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
734
+
735
+
[[package]]
736
+
name = "virtue"
737
+
version = "0.0.18"
738
+
source = "registry+https://github.com/rust-lang/crates.io-index"
739
+
checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
740
+
741
+
[[package]]
742
+
name = "winnow"
743
+
version = "0.7.13"
744
+
source = "registry+https://github.com/rust-lang/crates.io-index"
745
+
checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
746
+
dependencies = [
747
+
"memchr",
748
+
]
749
+
750
+
[[package]]
751
+
name = "xmrs"
752
+
version = "0.8.5"
753
+
source = "registry+https://github.com/rust-lang/crates.io-index"
754
+
checksum = "ebc0c419db3fe18554d886d2e9a18435683cef7f0ad8c502cc2bf9515a125744"
755
+
dependencies = [
756
+
"bincode",
757
+
"micromath",
758
+
"num_enum",
759
+
"serde",
760
+
"serde-big-array",
761
+
]
+1
Cargo.toml
+1
Cargo.toml
+47
DEV Cheat Sheet.md
+47
DEV Cheat Sheet.md
···
1
+
## Supported Sprite Sizes
2
+
3
+
| Size | Width | Height |
4
+
|-------|-------|--------|
5
+
| 8x8 | 8 | 8 |
6
+
| 16x16 | 16 | 16 |
7
+
| 32x32 | 32 | 32 |
8
+
| 64x64 | 64 | 64 |
9
+
| 16x8 | 16 | 8 |
10
+
| 32x8 | 32 | 8 |
11
+
| 32x16 | 32 | 16 |
12
+
| 64x32 | 64 | 32 |
13
+
| 8x16 | 8 | 16 |
14
+
| 8x32 | 8 | 32 |
15
+
| 16x32 | 16 | 32 |
16
+
| 32x64 | 32 | 64 |
17
+
18
+
19
+
## Gameboy Screen Size in pixels
20
+
WIDTH = 240 \
21
+
HEIGHT = 160
22
+
23
+
## X/Y
24
+
X - Horizontal \
25
+
Y - Vertical \
26
+
Vector2D(x, y)
27
+
28
+
29
+
## Positioning
30
+
31
+
| location | X | Y |
32
+
|--------------|-----|-----|
33
+
| Top Left | 0 | 0 |
34
+
| Top Right | 240 | 0 |
35
+
| Bottom Left | 0 | 160 |
36
+
| Bottom Right | 240 | 160 |
37
+
38
+
```
39
+
______________________________
40
+
| 0,0 240,0 |
41
+
| |
42
+
| |
43
+
| |
44
+
| |
45
+
|0,160 240,160|
46
+
------------------------------
47
+
```
gfx/flap_animated.aseprite
gfx/flap_animated.aseprite
This is a binary file and will not be displayed.
+80
-4
src/main.rs
+80
-4
src/main.rs
···
15
15
// until you declare the extern crate. `agb` provides an allocator so it will all work
16
16
extern crate alloc;
17
17
18
-
// The main function must take 1 arguments and never returns, and must be marked with
19
-
// the #[agb::entry] macro.
18
+
use agb::display::{GraphicsFrame, Priority};
19
+
use agb::display::object::Object;
20
+
use agb::fixnum::{num, vec2, FixedNum, Num, Vector2D};
21
+
use agb::include_aseprite;
22
+
use agb::input::Button;
23
+
24
+
include_aseprite!(
25
+
mod goose_sprites,
26
+
"gfx/flap_animated.aseprite"
27
+
);
28
+
29
+
type Fixed = Num<i32, 8>;
30
+
31
+
20
32
#[agb::entry]
21
-
fn main(gba: agb::Gba) -> ! {
22
-
agb::no_game(gba);
33
+
fn main(mut gba: agb::Gba) -> ! {
34
+
let mut gfx = gba.graphics.get();
35
+
let mut goose = Goose::new();
36
+
37
+
let mut button_controller = agb::input::ButtonController::new();
38
+
39
+
loop {
40
+
button_controller.update();
41
+
let mut frame = gfx.frame();
42
+
43
+
44
+
let just_pressed = button_controller.is_just_pressed(Button::A);
45
+
goose.move_goose(just_pressed);
46
+
goose.show(&mut frame);
47
+
frame.commit();
48
+
49
+
}
50
+
}
51
+
52
+
53
+
/// I really don't have a better name for these
54
+
#[derive(Copy, Clone)]
55
+
pub enum GooseState {
56
+
Zero = 0,
57
+
One = 1,
58
+
Two = 2,
59
+
Three = 3,
60
+
}
61
+
62
+
63
+
struct Goose {
64
+
pos: Vector2D<Fixed>,
65
+
velocity: Vector2D<Fixed>,
66
+
current_state: GooseState,
67
+
}
68
+
69
+
impl Goose {
70
+
pub fn new() -> Self {
71
+
Self {
72
+
pos: vec2(num!(5), num!(5)),
73
+
velocity: vec2(num!(0), num!(0)),
74
+
current_state: GooseState::Zero,
75
+
}
76
+
}
77
+
78
+
pub fn show(&mut self, frame: &mut GraphicsFrame) {
79
+
let _ = Object::new(goose_sprites::GOOSE.sprite(self.current_state as usize))
80
+
.set_pos(self.pos.round())
81
+
.set_priority(Priority::P1)
82
+
.show(frame);
83
+
84
+
}
85
+
86
+
pub fn move_goose(&mut self, button_pressed: bool) {
87
+
self.pos += self.velocity;
88
+
if button_pressed {
89
+
agb::println!("Just pressed: {:?}", self.velocity)
90
+
}
91
+
let y_velocity: Fixed = match button_pressed {
92
+
true => num!(-0.10),
93
+
false => num!(0.01),
94
+
};
95
+
96
+
self.velocity.y += y_velocity;
97
+
98
+
}
23
99
}