Skip to content

Commit f1f0fec

Browse files
committed
many changes
1 parent 49c4386 commit f1f0fec

File tree

22 files changed

+274
-225
lines changed

22 files changed

+274
-225
lines changed

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Leafy Engine is an engine inspired by [HaxeFlixel](https://haxeflixel.com/) for making 2D games for the Wii U using Haxe, yes, Haxe!
77

88
> [!IMPORTANT]
9-
> The engine is still in development, so there may be some bugs and many changes constantly!
9+
> The engine is still in development, so there may be some bugs, instability and many changes constantly!
1010
1111
[Leafy Engine Docs](https://github.com/Slushi-Github/leafyEngine/blob/main/docs/wiki/README.md)
1212

@@ -30,6 +30,12 @@ class PlayState extends LfState {
3030
sprite.createGraphic(200, 200, [255, 0, 0]);
3131
sprite.center();
3232
addObject(sprite);
33+
34+
var textSprite:LfText = new LfText(0, 0, "Hello World!", 32, "LeafyGame/font.ttf");
35+
textSprite.center();
36+
textSprite.y -= 120;
37+
textSprite.setColor(0, 0, 255);
38+
addObject(textSprite);
3339
}
3440
3541
// Update the sprite position
@@ -52,7 +58,7 @@ class PlayState extends LfState {
5258
}
5359
```
5460

55-
A code probably similar to one from [HaxeFlixel](https://haxeflixel.com/) right?
61+
A code probably similar to one from [HaxeFlixel](https://haxeflixel.com) right?
5662

5763
## Current status of the engine:
5864
- [x] Wii U Gamepad support
@@ -74,29 +80,33 @@ A code probably similar to one from [HaxeFlixel](https://haxeflixel.com/) right?
7480
- [x] States
7581
- [ ] Substates
7682
- [x] Collisions
77-
- [x] Sprites basic physics
83+
- [x] Sprites basic physics
7884
- [x] Tweens and easing functions
7985
- [x] JSONs file support (Only decoding)
8086
- [x] Timers (Using [``haxe.Timer``](https://api.haxe.org/haxe/Timer.html))
81-
- [x] HTTP requests (Via Curl)
82-
- [x] Multiple renders mode (``DRC``, ``TV`` and ``UNIQUE``)
87+
- [x] HTTP requests (Via CURL)
88+
- Engine rendering modes
89+
- [x] Only on the Wii U Gamepad (-> ``DRC``)
90+
- [x] Only on the TV (-> ``TV``)
91+
- [x] Both (-> ``UNIQUE``)
92+
- [ ] Separate rendering (Wii U Gamepad and TV independent at the same time)
8393
- [x] FileSystem manipulation
8494
- [ ] Engine cameras
8595

8696
## How?
87-
This engine uses [SDL2 (For the Wii U)](https://github.com/devkitPro/SDL/tree/wiiu-sdl2-2.28) as a base, along with other WUT functions. All the libraries are ported to Haxe to work through the ``@:native`` feature, to finally use [Reflaxe/C++](https://github.com/SomeRanDev/reflaxe.CPP) to generate the code in C++ and compile it through the [DevKitPPC](https://wiibrew.org/wiki/DevkitPPC) tools, although due to this mode, there are things that change and have more care in how the engine is used when you want to make a project with it.
97+
This engine uses [SDL2 (For the Wii U)](https://github.com/devkitPro/SDL/tree/wiiu-sdl2-2.28) as a base, along with other [WUT](https://github.com/devkitPro/wut) functions. All the libraries are ported to Haxe to work through the ``@:native`` feature, to finally use [Reflaxe/C++](https://github.com/SomeRanDev/reflaxe.CPP) to generate the code in C++ and compile it through the [DevKitPPC](https://wiibrew.org/wiki/DevkitPPC) tools, although due to this mode, there are things that change and have more care in how the engine is used when you want to make a project with it.
8898

8999
## Why?
90-
Haxe has always fascinated me since I met him modifying [Friday Night Funkin'](https://github.com/FunkinCrew/Funkin) from 2022 (The result of that was the [Slushi Engine](https://github.com/Slushi-Github/Slushi-Engine)). And there was a time when I was really interested in getting a Nintendo Wii U, I knew it was a console that was not very popular and that kind of thing... But my interest was highly elevated by wanting to make my own homebrew for the console, and I wanted to try Haxe, unfortunately, although there was [an attempt to bring Haxe to the Wii U](https://www.fortressofdoors.com/openfl-for-home-game-consoles), it was forgotten, besides needing to be registered in the Nintendo Developer, a lot of problems right?.
100+
Haxe has always fascinated me since I met him modifying [Friday Night Funkin'](https://github.com/FunkinCrew/Funkin) from 2022 (The result of that was the [Slushi Engine](https://github.com/Slushi-Github/Slushi-Engine)). And there was a time when I was really interested in getting a Nintendo Wii U, I knew it was a console that was not very popular and that kind of thing... But my interest was highly elevated by wanting to make my own homebrew for the console, and I wanted to try Haxe, unfortunately, although there was [an attempt to bring Haxe to the Wii U](https://www.fortressofdoors.com/openfl-for-home-game-consoles), it was forgotten (Or I think it is only maintained for Nintendo Switch at the moment), besides needing to be registered in the Nintendo Developer Portal, a lot of problems right?.
91101

92-
After months and months, after having managed to make the [HxCompileU project](https://github.com/Slushi-Github/hxCompileU) stable and viable, I now present, this, Leafy Engine, an engine that will try to be like HaxeFlixel, and create your games on this underrated console.
102+
After months and months, after having managed to make the [HxCompileU project](https://github.com/Slushi-Github/hxCompileU) stable and viable, I now present, this, Leafy Engine, an engine that will try to be like [HaxeFlixel](https://haxeflixel.com), and create your games on this underrated console.
93103

94104
## Using the engine
95105

96106
Read the [Getting Started](https://github.com/Slushi-Github/leafyEngine/blob/main/docs/wiki/Getting-Started.md) page
97107

98108
## Contributing
99-
If you want to contribute to this project, you can do it by creating a pull request on this repository, test that your changes work both in [Cemu](https://github.com/cemu-project/Cemu) and on the real hardware, I would recommend attaching images if it is a change that can be shown.
109+
If you want to contribute to this project, you can do it by creating a pull request on this repository, test that your changes work both in [Cemu](https://github.com/cemu-project/Cemu) __**and on the real hardware**__, I would recommend attaching images if it is a change that can be shown.
100110

101111
## Credits
102112
- [DevkitPro](https://devkitpro.org): The base of the homebrew development on Wii U

docs/wiki/Getting-Started.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Installation
2-
Assuming you already have Haxe, create a new folder where you want your project to be, then open a terminal in that folder and do the first command:
2+
Assuming you already have Haxe, And a Wii U with Aroma installed (Or an emulator, like [Cemu](https://github.com/cemu-project/Cemu)), create a new folder where you want your project to be, then open a terminal in that folder and do the first command:
33

44
```bash
55
haxelib newrepo
@@ -36,7 +36,17 @@ When you have everything, install the following:
3636

3737
(include the ``dkp-`` if you're on Linux or MacOS)
3838
```bash
39-
(dkp-)pacman -Syu --needed wiiu-dev wiiu-curl wiiu-sdl2 wiiu-sdl2-image wiiu-sdl2-mixer wiiu-sdl2-ttf wiiu-sdl2_gfx ppc-jansson ppc-zlib ppc-libvorbis ppc-libopus ppc-libogg ppc-libjpeg-turbo ppc-freetype ppc-bzip2 ppc-libpng
39+
# Install the Wii U dependencies
40+
(dkp-)pacman -Syu --needed wiiu-dev
41+
42+
# Install the Wii U SDL2 libraries
43+
(dkp-)pacman -Syu wiiu-sdl2 wiiu-sdl2_gfx wiiu-sdl2_image wiiu-sdl2_mixer wiiu-sdl2_ttf
44+
45+
# Install the PowerPC libraries
46+
(dkp-)pacman -Syu ppc-jansson ppc-zlib ppc-libvorbis ppc-libopus ppc-libogg ppc-libjpeg-turbo ppc-freetype ppc-bzip2 ppc-libpng
47+
48+
# And finally the Wii U CURL library
49+
(dkp-)pacman -Syu wiiu-curl
4050
```
4151

4252
Now you're ready to start coding!
@@ -56,9 +66,11 @@ import leafy.LfEngine;
5666
class Main {
5767
public static function main() {
5868
/*
69+
"YOUR_GAME" = The name of your game, this will be the name of the folder where you'll find your assets
5970
DRC = Display the game on the Wii U Gamepad
6071
TV = Display the game on the TV
6172
UNIQUE = Display the game on a unique screen (Gamepad and TV)
73+
``YOUR_STATE()`` = The class of the state (LfState) you want to start the game in
6274
*/
6375
LfEngine.initEngine("YOUR_GAME", DRC, new YOUR_STATE());
6476
}
@@ -67,6 +79,6 @@ class Main {
6779

6880
That ``YOUR_STATE()`` is the class of the state (``LfState``) you want to start the game in.
6981

70-
it's like when you start a Flixel game (``addChild(new FlxGame(800, 600, new PlayState, ...));``)
82+
it's like when you start a HaxeFlixel game (``addChild(new FlxGame(800, 600, new PlayState, ...));``)
7183

7284
Then, run ``haxeCompileU --compile`` and you're ready to go!

docs/wiki/sections/FolderSections/Audio.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
Leafy Engine uses a audio engine that uses the [Vorbis](https://github.com/Haxe-WiiU/HxU_Vorbis) library and SDL_Audio to play audio OGG files in the engine.
44

5-
Unfortunately, there is a major limitation in this audio engine, I can't get more than one audio to play at a time without slowing down the sound reproduction or even getting a crash, so I will only use one audio at a time.
5+
Unfortunately, there is a major limitation in this audio engine, I can't get more than one audio to play at a time without slowing down the sound reproduction or even getting a console crash, so I will only use one audio at a time.
6+
7+
#### **As a recommendation**, SDL_Audio by default is started to expect audio that is on frequency *``44100``* and has __2__ audio channels. While the audio engine is able to detect if the audio being loaded has any difference in those 2 values, what it will do is reopen the entire audio device, causing there to be a significant lag when that happens. For that reason I recommend to verify if your audio (sound, music) is in the frequency *``44100``* and that it has __2__ audio channels, otherwise you can convert it using some web page or a tool that allows you to do that.
8+
9+
--------
610

711
To use it is easy, here is an example:
812
```haxe
@@ -37,7 +41,7 @@ var currentTime:Float = Leafy.audio.getCurrentTime();
3741
var duration:Float = Leafy.audio.getDuration();
3842
```
3943

40-
----
44+
--------
4145

4246
See [``LfAudioEngine``](https://github.com/Slushi-Github/leafyEngine/blob/main/leafy/audio/LfAudioEngine.hx)
4347

docs/wiki/sections/FolderSections/Sprites.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var sprite:LfSprite = new LfSprite(100, 100);
1515
1616
// create a graphic
1717
// The ``createGraphic`` function takes 3 parameters, the width, height and the color of the graphic.
18-
sprite.createGraphic(200, 200, [255, 0, 0, 255]);
18+
sprite.createGraphic(200, 200, [255, 0, 0]);
1919
2020
// Load an image
2121
sprite.loadImage("GAME_PATH/image.png");
@@ -24,7 +24,7 @@ sprite.loadImage("GAME_PATH/image.png");
2424
addObject(sprite);
2525
```
2626

27-
-----
27+
--------
2828

2929
## LfText
3030

@@ -41,7 +41,8 @@ var text:LfText = new LfText(100, 100, "Hello World!", 32, "GAME_PATH/FONT.ttf")
4141
addObject(text);
4242
```
4343

44-
-----
44+
--------
45+
4546
See [``LfSprite``](https://github.com/Slushi-Github/leafyEngine/blob/main/leafy/objects/LfSprite.hx)
4647

4748
See [``LfText``](https://github.com/Slushi-Github/leafyEngine/blob/main/leafy/objects/LfText.hx)

docs/wiki/sections/FolderSections/Tweens.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ var tween:LfTween = new LfTween(sprite, LfTweenProperty.X, sprite.x, 200, 3, LfT
1515
LfTween.cancelTween(tween);
1616
```
1717

18-
-----
18+
--------
19+
1920
See [``LfTween``](https://github.com/Slushi-Github/leafyEngine/blob/main/leafy/tweens/LfTween.hx)

docs/wiki/sections/FolderSections/WiiU_Gamepad.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ var touchPos:LfVector2D = Leafy.wiiuGamepad.getTouch();
6767
var isTouchObject:Bool = Leafy.wiiuGamepad.isTouchingAObject(object:LfObject);
6868
```
6969

70+
--------
71+
7072
You can use the gyroscope and accelerometer:
7173
```haxe
7274
// import the Leafy class
@@ -86,15 +88,15 @@ For use the rumble, it would be done in this way:
8688
// import the Leafy class
8789
import leafy.Leafy;
8890
89-
// start the rumble
91+
// start the vibration of the Wii U Gamepad
9092
/*
91-
The first parameter is the intensity of the rumble, from 0 to 1
92-
The second parameter is the duration of the rumble, in seconds, -1 for infinite
93+
The first parameter is the intensity of the vibration, from 0 to 1
94+
The second parameter is the duration of the vibration, in seconds, -1 for infinite
9395
*/
94-
Leafy.wiiuGamepad.startRumble(1, -1);
96+
Leafy.wiiuGamepad.vibrate(1, -1);
9597
96-
// stop the rumble
97-
Leafy.wiiuGamepad.stopRumble();
98+
// stop the vibration
99+
Leafy.wiiuGamepad.stopVibration();
98100
```
99101

100102
<!-- --------

leafy/LfEngine.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LfEngine {
3030
/**
3131
* The current version of the engine
3232
*/
33-
public static var version:String = "1.4.3";
33+
public static var VERSION:String = "1.4.6";
3434

3535
/**
3636
* Function to be called when the engine exits
@@ -61,7 +61,7 @@ class LfEngine {
6161
Proc.WHBProcInit();
6262
Crash.WHBInitCrashHandler(); // This really works?
6363

64-
Sys.println("[Leafy Engine initial state - no logger started] Starting Leafy Engine " + version);
64+
Sys.println("[Leafy Engine initial state - no logger started] Starting Leafy Engine [" + VERSION + "]");
6565

6666
if (renderMode == null) {
6767
Sys.println("[Leafy Engine initial state - no logger started -> WARNING] Render mode cannot be null, defaulting to DRC mode");
@@ -86,7 +86,7 @@ class LfEngine {
8686
// Initialize the Wii U Gamepad
8787
LfGamepadInternal.initDRC();
8888

89-
LeafyDebug.log("Leafy Engine [" + version + "] initialized", INFO);
89+
LeafyDebug.log("Leafy Engine [" + VERSION + "] initialized", INFO);
9090

9191
// Set and initialize the initial state
9292
LfStateHandler.initFirstState(state);
@@ -108,7 +108,7 @@ class LfEngine {
108108
onEngineExit();
109109
}
110110

111-
LeafyDebug.log("Shutting down Leafy Engine " + version, INFO);
111+
LeafyDebug.log("Shutting down Leafy Engine [" + VERSION + "]", INFO);
112112

113113
LfStateHandler.destroyCurrentState();
114114
SubEngines.shutdownSDL();

leafy/audio/LfAudio.hx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class LfAudio {
7272
var correctPath:String = LfSystemPaths.getConsolePath() + path;
7373

7474
if (!LfSystemPaths.exists(correctPath)) {
75-
LeafyDebug.log("Failed to load OGG [" + path + "]: File not found", INFO);
75+
LeafyDebug.log("Failed to load OGG [" + path + "]: File not found", ERROR);
7676
return;
7777
}
7878

@@ -81,13 +81,13 @@ class LfAudio {
8181
file = new OggVorbis_File();
8282
// SDL_Stdinc.SDL_zero(currentFile.ref);
8383
if (VorbisFile.ov_fopen(ConstCharPtr.fromString(correctPath), file) != 0) {
84-
LeafyDebug.log("Failed to load OGG [" + path + "]: " + SDL_Error.SDL_GetError().toString(), INFO);
84+
LeafyDebug.log("Failed to load OGG [" + path + "]: " + SDL_Error.SDL_GetError().toString(), ERROR);
8585
return;
8686
}
8787

8888
info = untyped __cpp__("ov_info(leafy::audio::LfAudio::file, -1)");
8989
if (info == null) {
90-
LeafyDebug.log("Failed to get OGG info for [" + path + "]: " + SDL_Error.SDL_GetError().toString(), INFO);
90+
LeafyDebug.log("Failed to get OGG info for [" + path + "]: " + SDL_Error.SDL_GetError().toString(), ERROR);
9191
return;
9292
}
9393

@@ -97,7 +97,7 @@ class LfAudio {
9797
paused = false;
9898
this.loop = loop;
9999

100-
LeafyDebug.log("Loaded OGG: [" + path + "] with duration: " + duration + " seconds" , INFO);
100+
LeafyDebug.log("Loaded OGG: [" + path + "] with duration: " + duration + " seconds" , DEBUG);
101101
return;
102102
}
103103

@@ -131,17 +131,6 @@ class LfAudio {
131131
return playing;
132132
}
133133

134-
// /**
135-
// *
136-
// */
137-
// public function fadeOut(duration:Float, onComplete:Void->Void):Void {
138-
// if (fadeTween != null) LfTween.cancelTween(this.fadeTween);
139-
// fadeTween = LfTween.tweenNumber(this.);
140-
// }
141-
142-
// public function update():Void {
143-
// }
144-
145134
/**
146135
* Destroys the OGG and frees memory
147136
*/

leafy/backend/LeafyDebug.hx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ enum LogLevel {
2424
WARNING;
2525
ERROR;
2626
DEBUG;
27-
CRITICAL;
2827
}
2928

3029
@:cppFileCode("
@@ -94,13 +93,29 @@ class LeafyDebug {
9493
* @param level The log level
9594
*/
9695
@:include("haxe_PosInfos.h")
97-
public static function log(msg:String, level:LogLevel, ?pos:PosInfos):Void {
98-
if (level == LogLevel.CRITICAL) {
96+
public static function log(msg:String = "", level:LogLevel = LogLevel.INFO, ?pos:PosInfos):Void {
97+
#if !debug
98+
if (level == LogLevel.DEBUG) {
9999
return;
100100
}
101+
#end
101102

102103
var formattedMessage:String = prepareText(msg, level, pos);
103104

105+
// Log to the Wii U console debug output (Maybe "/storage_slc/sys/logs"?)
106+
switch (level) {
107+
case LogLevel.INFO:
108+
Debug.OSReportInfo(ConstCharPtr.fromString(formattedMessage));
109+
case LogLevel.WARNING:
110+
Debug.OSReportWarn(ConstCharPtr.fromString(formattedMessage));
111+
case LogLevel.ERROR:
112+
Debug.OSReportWarn(ConstCharPtr.fromString(formattedMessage));
113+
case LogLevel.DEBUG:
114+
Debug.OSReportVerbose(ConstCharPtr.fromString(formattedMessage));
115+
default:
116+
Debug.OSReportInfo(ConstCharPtr.fromString(formattedMessage));
117+
}
118+
104119
if (!started) {
105120
Sys.println("[Leafy Engine - no logger started] | " + formattedMessage);
106121
return;
@@ -145,7 +160,7 @@ class LeafyDebug {
145160
var logFile = logsDir + "leafyLog_" + currentTimeMod + "-" + currentDateMod + ".txt";
146161

147162
if (!LfSystemPaths.exists(logFile)) {
148-
LfFile.writeFile(logFile, "Leafy Engine [" + LfEngine.version + "] Log File\n" + " - " + currentDateStr + " | " + currentTimeStr + "\n-------------------\n\n");
163+
LfFile.writeFile(logFile, "Leafy Engine [" + LfEngine.VERSION + "] Log File\n" + " - " + currentDateStr + " | " + currentTimeStr + "\n-------------------\n\n");
149164
}
150165

151166
currentLogFile = logFile;
@@ -182,7 +197,7 @@ class LeafyDebug {
182197
*/
183198
private static function getHaxeFilePos(pos:PosInfos):String {
184199
if (pos == null) {
185-
return "UnknownLocation";
200+
return "UnknownPosition";
186201
}
187202

188203
return pos.className + "/" + pos.methodName + ":" + pos.lineNumber;
@@ -195,7 +210,7 @@ class LeafyDebug {
195210
*/
196211
private static function getHaxeFilePosForCrash(pos:PosInfos):String {
197212
if (pos == null) {
198-
return "UnknownLocation";
213+
return "UnknownPosition";
199214
}
200215

201216
return pos.fileName + ":\n\t" + pos.className + "." + pos.methodName + ":" + pos.lineNumber;
@@ -221,8 +236,6 @@ class LeafyDebug {
221236
levelStr = "ERROR";
222237
case LogLevel.DEBUG:
223238
levelStr = "DEBUG";
224-
case LogLevel.CRITICAL:
225-
levelStr = "CRITICAL";
226239
}
227240

228241
str += "[" + getCurrentTime() + " (" + elapsedTime + ") | " + levelStr + " - " + getHaxeFilePos(pos) + "] " + text + "\n";
@@ -235,13 +248,14 @@ class LeafyDebug {
235248
* @param pos
236249
*/
237250
private static function crashConsole(crashError:String, ?pos:PosInfos):Void {
238-
var strPtr:ConstCharPtr = ConstCharPtr.fromString("[Leafy Engine " + LfEngine.version + " logger - " + getCurrentTime()
251+
var strPtr:ConstCharPtr = ConstCharPtr.fromString("[Leafy Engine " + LfEngine.VERSION + " logger - " + getCurrentTime()
239252
+ " - CRASH]\n\nCall stack:\n" + getHaxeFilePosForCrash(pos) + "\n\nError: " + crashError
240253
+ "\n\n\n\t\t Please reset the console.");
241254

242255
LfFile.appendToFile(currentLogFile, "---------------------");
243256
log("CRASH: " + crashError, ERROR, pos);
244-
log("Stopping the engine and console due to crash...", ERROR, pos);
257+
log("Call stack:\n\t" + getHaxeFilePosForCrash(pos), ERROR, pos);
258+
log("Executing WUT OSFatal call for crash...", ERROR, pos);
245259

246260
Debug.OSFatal(strPtr);
247261
}

0 commit comments

Comments
 (0)