Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 2bbbeef

Browse files
committed
Merge remote branch 'origin/main'
2 parents 21fd551 + 142ac0b commit 2bbbeef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+17561
-1640
lines changed

docs/animation.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
# nene/animation.nelua
2-
## Nene.AnimationRange (record)
1+
## animation
2+
3+
Animation range type, used on Spritesheets
4+
5+
### AnimationRange
36

47
```lua
5-
global Nene.AnimationRange = @record{
6-
name: string,
7-
fps: number,
8-
from: usize,
9-
to: usize,
8+
global AnimationRange = @record{
9+
fps: number, -- frames per second of this animation
10+
from: usize, -- first frame
11+
to: usize, -- last frame
1012
}
1113
```
1214

13-
## Nene.AnimationRange.__eq (function)
15+
Animation range type, used on Spritesheets
16+
17+
### AnimationRange.__eq
1418

1519
```lua
16-
function Nene.AnimationRange.__eq(l: Nene.AnimationRange, r: Nene.AnimationRange): boolean
20+
function AnimationRange.__eq(l: AnimationRange, r: AnimationRange): boolean
1721
```
22+
23+
checks equality between animation ranges
24+
25+
---

docs/audio.md

Lines changed: 111 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,142 @@
1-
# nene/audio.nelua
2-
## Nene.Sound (record)
1+
### Sound
32

43
```lua
5-
global Nene.Sound = @record{
6-
_data: *Mix_Chunk,
4+
global Sound = @record{
5+
_data: *Mix_Chunk, -- internal data, don't use it directly, use methods instead
76
channel: integer, -- -1 when no channel is being used
87
}
98
```
109

11-
## Nene.Sound:play (function)
10+
Wraps a (SDL_mixer) sound associated with a sound channel
11+
12+
### Sound:get
1213

1314
```lua
14-
function Nene.Sound:play(loop: overload(boolean, integer, niltype))
15+
function Sound:get(): *Mix_Chunk
1516
```
1617

17-
## Nene.Sound:stop (function)
18+
It checks if the internal data is `nilptr` and then returns it.
19+
20+
Related SDL_mixer documentation:
21+
* [Mix_Chunk](https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_85.html#SEC85)
22+
23+
### Sound.load
1824

1925
```lua
20-
function Nene.Sound:stop()
26+
function Sound.load(filename: string): (Sound, boolean)
2127
```
2228

23-
## Nene.Sound:free (function)
29+
try to load a sound from a file.
30+
31+
it returns:
32+
* `Sound` value, with internal data properly initialized if load is successful
33+
* a boolean which is `true` when the load succeeds.
34+
35+
Related MixWrapper documentation:
36+
* [MixWrapper.load_wav](wrappers/mix.md#mixwrapperload_wav)
37+
38+
### Sound:play
2439

2540
```lua
26-
function Nene.Sound:free()
41+
function Sound:play(loop: overload(boolean, integer, niltype))
2742
```
2843

29-
## Nene.Sound:stop_and_free (function)
44+
plays the loaded sound.
45+
* if `true` is passed on `loop` argument, the sound will loop forever;
46+
* if an `integer` is passed, the sound will loop `loop` times
47+
* if `nil` is passed, it will play only one time.
48+
49+
When there is no sound loaded (that is, the internal data is `nilptr`), then this method
50+
does nothing, though it also `check`s if the internal is `nilptr` (unless the `nochecks` pragma is enabled)
51+
52+
Related MixWrapper documentation:
53+
* [MixWrapper.play_channel](wrappers/mix.md#mixwrapperplay_channel)
54+
55+
### Sound:stop
3056

3157
```lua
32-
function Nene.Sound:stop_and_free()
58+
function Sound:stop()
3359
```
3460

35-
## Nene.Music (record)
61+
Halts (stop, interrupt) the sound.
62+
63+
Related MixWrapper documentation:
64+
* [MixWrapper.halt_channel](wrappers/mix.md#mixwrapperhalt_channel)
65+
66+
### Sound:destroy
3667

3768
```lua
38-
global Nene.Music = @record{
69+
function Sound:destroy()
70+
```
71+
72+
Destroy the sound and resets to zeroed state,
73+
74+
> Note: It will first stop the sound and then free the sound's memory.
75+
76+
Related MixWrapper documentation:
77+
* [MixWrapper.free_chunk](wrappers/mix.md#mixwrapperfree_chunk)
78+
79+
### Music
80+
81+
```lua
82+
global Music = @record{
3983
_data: *Mix_Music,
40-
id: usize,
4184
}
4285
```
4386

44-
## Nene.Music:free (function)
87+
Wraps a (SDL_mixer) music
88+
89+
### Music:get
90+
91+
```lua
92+
function Music:get(): *Mix_Music
93+
```
94+
95+
It checks if the internal data is `nilptr` and then returns it.
96+
97+
Related SDL_mixer documentation:
98+
* [Mix_Music](https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_86.html#SEC86)
99+
100+
### Music:play
101+
102+
```lua
103+
function Music:play(loops: facultative(integer))
104+
```
105+
106+
Plays the music (forever by default), note that this stops any playing music.
107+
108+
You can also pass a `loop` argument, this makes the music loop `loop` times, also note that:
109+
* Passing `0` will make it play the music `0` times.
110+
* Passing `1` will make it only once.
111+
* Passing `-1` will make it looping forever, this is the default value.
112+
113+
Related MixWrapper documentation:
114+
* [MixWrapper.play_music](wrappers/mix.md#mixwrapperplay_music)
115+
* [MixWrapper.halt_music](wrappers/mix.md#mixwrapperhalt_music)
116+
117+
### Music.stop
45118

46119
```lua
47-
function Nene.Music:free()
120+
function Music.stop()
48121
```
122+
123+
Stops any playing music.
124+
125+
Related MixWrapper documentation:
126+
* [MixWrapper.halt_music](wrappers/mix.md#mixwrapperhalt_music)
127+
* [MixWrapper.play_music](wrappers/mix.md#mixwrapperplay_music)
128+
129+
### Music:destroy
130+
131+
```lua
132+
function Music:destroy()
133+
```
134+
135+
Destroy the music and resets to zeroed state.
136+
137+
> Note: SDL_mixer first halts the music if it's playing, it also wait if it's still fading out.
138+
139+
Related MixWrapper documentation:
140+
* [MixWrapper.free_music](wrappers/mix.md#mixwrapperfree_music)
141+
142+
---

docs/camera.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1 @@
1-
# nene/camera.nelua
2-
## Nene.Camera (record)
3-
4-
```lua
5-
global Nene.Camera = @record{
6-
offset: Nene.Math.Vec2, -- should be on ([0, 1], [0, 1]) range
7-
pos: Nene.Math.Vec2,
8-
}
9-
local Camera = Nene.Camera
10-
## Camera.value.is_camera = true
11-
```
12-
13-
## Camera:set_offset (function)
14-
sets the offset vector of camera, it's {0.5, 0.5} by default, which
15-
means that the objects will look
16-
offset is how the camera centers on the screen, you probably want
17-
```lua
18-
function Camera:set_offset(offset: Nene.Math.Vec2)
19-
```
20-
21-
## Camera:get_relative_pos (function)
22-
23-
```lua
24-
function Camera:get_relative_pos(pos: Nene.Math.Vec2, screen_size: Nene.Math.Vec2): Nene.Math.Vec2
25-
```
26-
27-
## Camera.new (function)
28-
29-
```lua
30-
function Camera.new(pos: facultative(Nene.Math.Vec2)): Camera
31-
```
1+
---

docs/colors.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
# nene/colors.nelua
1+
### Color
2+
3+
```lua
4+
global Color = @SDL_Color
5+
```
6+
7+
`Nene.Color` is an alias of `SDL_Color`, see it's documentation for more information.
8+
9+
Related SDL documentation:
10+
* [SDL_Color](https://wiki.libsdl.org/SDL_Color)
11+
12+
### Color.Palette
13+
14+
```lua
15+
global Color.Palette: record{
16+
black: Color,
17+
white: Color,
18+
red: Color,
19+
green: Color,
20+
blue: Color,
21+
yellow: Color,
22+
cyan: Color,
23+
bg: Color,
24+
}
25+
```
26+
27+
The general color pallete of Nene
28+
29+
> Note: This is not related to [`SDL_Pallete`](https://wiki.libsdl.org/SDL_Palette) data structure.
30+
31+
---

0 commit comments

Comments
 (0)