Skip to content

Commit

Permalink
Some improvements and updated bindings with new bindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre-LA committed Apr 13, 2023
1 parent 09c0873 commit 6b6c42b
Show file tree
Hide file tree
Showing 24 changed files with 255 additions and 285 deletions.
13 changes: 5 additions & 8 deletions bindings/nelua/nene/animation.nelua
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
## linklib 'nene'
## cinclude '"nene/animation.h"'



-- Animation range type, used on Spritesheets
--
-- The fields are:
-- - interval: animation speed
-- - from: starting frame of the animation (inclusive)
-- - to: ending frame of the animation (inclusive)
-- - properties: animation properties
local Animation <cimport 'nene_Animation', nodecl> = @record{
-- animation speed
interval: uint16,
-- starting frame of the animation (inclusive)
from: uint16,
-- ending frame of the animation (inclusive)
to: uint16,
-- animation properties
loop: boolean,
}

-- Tests if a and b animation ranges are equal.
function Animation.__eq(a: Animation, b: Animation): boolean <cimport 'nene_Animation_equals', nodecl> end


return Animation
21 changes: 12 additions & 9 deletions bindings/nelua/nene/audio/music.nelua
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
## linklib 'nene'
## cinclude '"nene/audio/music.h"'

## cinclude '<SDL2/SDL_mixer.h>'


require 'nene.raw.sdl2_mixer'



local Music <cimport 'nene_Music', nodecl> = @record{

raw: *Mix_Music,
}


local MusicCreation <cimport 'nene_MusicCreation', nodecl> = @record{

created: boolean,

music: Music,
}


function Music.get_raw(music: Music): *Mix_Music <cimport 'nene_Music_get_raw', nodecl> end


local function Music_load(filepath: cstring): MusicCreation <cimport 'nene_Music_load', nodecl> end

local function nene_Music_load(filepath: cstring): MusicCreation <cimport 'nene_Music_load', nodecl> end

function Music.play(music: Music, loops: int16): boolean <cimport 'nene_Music_play', nodecl> end


function Music.stop(): void <cimport 'nene_Music_stop', nodecl> end


function Music.set_volume(volume: float32): float32 <cimport 'nene_Music_set_volume', nodecl> end


function Music.destroy(music: *Music): void <cimport 'nene_Music_destroy', nodecl> end

local Music.Creation = @MusicCreation

local Music.Creation: type = @MusicCreation

function Music.load(filepath: cstring): (boolean, Music)
local music_creation: MusicCreation = Music_load(filepath)
local music_creation: MusicCreation = nene_Music_load(filepath)
return music_creation.created, music_creation.music
end

function Music:__close()
self:destroy()
end



return Music
23 changes: 13 additions & 10 deletions bindings/nelua/nene/audio/sound.nelua
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
## linklib 'nene'
## cinclude '"nene/audio/sound.h"'

## cinclude '<SDL2/SDL_mixer.h>'


require 'nene.raw.sdl2_mixer'



local Sound <cimport 'nene_Sound', nodecl> = @record{

raw: *Mix_Chunk,

channel: int16,
}


local SoundCreation <cimport 'nene_SoundCreation', nodecl> = @record{

created: boolean,

sound: Sound,
}


function Sound.get_raw(sound: Sound): *Mix_Chunk <cimport 'nene_Sound_get_raw', nodecl> end


local function Sound_load(filepath: cstring): SoundCreation <cimport 'nene_Sound_load', nodecl> end

local function nene_Sound_load(filepath: cstring): SoundCreation <cimport 'nene_Sound_load', nodecl> end

function Sound.play(sound: *Sound, loops: int16): boolean <cimport 'nene_Sound_play', nodecl> end


function Sound.halt(sound: *Sound): boolean <cimport 'nene_Sound_halt', nodecl> end


function Sound.halt_all(): boolean <cimport 'nene_Sound_halt_all', nodecl> end


function Sound.set_volume(sound: Sound, volume: float32): float32 <cimport 'nene_Sound_set_volume', nodecl> end


function Sound.destroy(sound: *Sound): void <cimport 'nene_Sound_destroy', nodecl> end

local Sound.Creation = @SoundCreation

local Sound.Creation: type = @SoundCreation

function Sound.load(filepath: cstring): (boolean, Sound)
local sound_creation: SoundCreation = Sound_load(filepath)
local sound_creation: SoundCreation = nene_Sound_load(filepath)
return sound_creation.created, sound_creation.sound
end

function Sound:__close()
self:destroy()
end



return Sound
9 changes: 4 additions & 5 deletions bindings/nelua/nene/collision.nelua
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
## linklib 'nene'
## cinclude '"nene/collision.h"'

local Segment = require 'nene.math.segment'
local Vec2 = require 'nene.math.vec2'
local Rectf = require 'nene.math.rectf'
local Segment = require 'nene.math.segment'


-- Collision data structure.
local Collision <cimport 'nene_Collision', nodecl> = @record{

collided: boolean,

delta: Vec2,
}

-- Returns "no collision" value.
function Collision.no_collision(): Collision <cimport 'nene_Collision_no_collision', nodecl> end

-- Returns the collision response between two rects.
function Collision.rectf_with_rectf(a: Rectf, b: Rectf, delta_pos: Vec2): Collision <cimport 'nene_Collision_rectf_with_rectf', nodecl> end

-- Returns the collision response between a rectangle and a segment.
function Collision.rectf_with_segment(rect: Rectf, segment: Segment, delta_pos: Vec2): Collision <cimport 'nene_Collision_rectf_with_segment', nodecl> end


return Collision
26 changes: 14 additions & 12 deletions bindings/nelua/nene/color.nelua
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
## linklib 'nene'
## cinclude '"nene/color.h"'

## cinclude '<SDL2/SDL.h>'


require 'nene.raw.sdl2'


-- Alias to SDL_color
local Color = @SDL_Color
local Color: type = @SDL_Color


local Color.black: Color <cimport 'nene_Color_black', nodecl>;
function Color.__eq(a: Color, b: Color): boolean <cimport 'nene_Color_equals', nodecl> end

-- The "black" color of nene's palette (`{ .r = 0x00, .g = 0x00, .b = 0x00, .a = 0xff }`)
local Color.black: Color <cimport 'nene_Color_black', nodecl>;

-- The "white" color of nene's palette (`{ .r = 0xff, .g = 0xff, .b = 0xff, .a = 0xff }`)
local Color.white: Color <cimport 'nene_Color_white', nodecl>;


-- The "red" color of nene's palette (`{ .r = 0xff, .g = 0x00, .b = 0x00, .a = 0xff }`)
local Color.red: Color <cimport 'nene_Color_red', nodecl>;


-- The "green" color of nene's palette (`{ .r = 0x00, .g = 0xff, .b = 0x00, .a = 0xff }`)
local Color.green: Color <cimport 'nene_Color_green', nodecl>;


-- The "blue" color of nene's palette (`{ .r = 0x00, .g = 0x00, .b = 0xff, .a = 0xff }`)
local Color.blue: Color <cimport 'nene_Color_blue', nodecl>;


-- The "yellow" color of nene's palette (`{ .r = 0xfc, .g = 0xea, .b = 0x20, .a = 0xff }`)
local Color.yellow: Color <cimport 'nene_Color_yellow', nodecl>;


-- The "cyan" color of nene's palette (`{ .r = 0x00, .g = 0xff, .b = 0xff, .a = 0xff }`)
local Color.cyan: Color <cimport 'nene_Color_cyan', nodecl>;


-- The "bg" color of nene's palette (`{ .r = 0x69, .g = 0x46, .b = 0x6b, .a = 0xff }`)
local Color.bg: Color <cimport 'nene_Color_bg', nodecl>;


function Color.__eq(a: Color, b: Color): boolean <cimport 'nene_Color_equals', nodecl> end

return Color
Loading

0 comments on commit 6b6c42b

Please sign in to comment.