Skip to content

Commit

Permalink
a1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
oblerion committed Aug 12, 2024
1 parent 337b599 commit b1e94d1
Show file tree
Hide file tree
Showing 60 changed files with 9,415 additions and 284 deletions.
Binary file modified .egba.conf
Binary file not shown.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
egba_a1.5-2_linux.zip
egba_a1.5-2_win32.zip
egba_a1.6_linux.zip
egba_a1.6_win32.zip
egba_a1.7_linux.zip
egba_a1.7_manual.zip
egba_a1.7_win32.zip
egba_a1.7.2_linux.zip
egba_a1.7.2_win32.zip
build/linux64/Editor.o
build/linux64/EGBA.o
build/linux64/main.o
build/linux64/Runner.o
build/win86/Editor.o
build/win86/EGBA.o
build/win86/main.o
build/win86/Runner.o
egba.exe
egba
src/gui/rguilayout
12 changes: 8 additions & 4 deletions WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
- [x] btn id 4 5 -> x c
- [x] lua api rename print -> text
## lua/egba save-load static data
- [ ] data to egba
- [ ] .sav file for lua
- [ ] function get data
- [ ] function set data
- [x] .sav file for lua
- [x] function get data
- [x] function set data
## interverse
- [x] launch script/egba lua
- [x] entry point
- [x] read extern save
- [ ] rename project
Binary file modified build/linux64/Editor.o
Binary file not shown.
Binary file modified build/linux64/Runner.o
Binary file not shown.
Binary file modified build/linux64/main.o
Binary file not shown.
Binary file modified build/win86/Editor.o
Binary file not shown.
Binary file modified build/win86/Runner.o
Binary file not shown.
Binary file modified build/win86/main.o
Binary file not shown.
Binary file modified egba
Binary file not shown.
Binary file modified egba.exe
Binary file not shown.
Binary file added egba_manual_a1.6.odt
Binary file not shown.
Binary file added egba_manual_a1.6.pdf
Binary file not shown.
Binary file added egba_manual_a1.7.odt
Binary file not shown.
Binary file added egba_manual_a1.7.pdf
Binary file not shown.
9 changes: 6 additions & 3 deletions make
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LUAWIN="/home/desnot/GD/lua-5.4.2/lua_win"
LUAWEB="/home/desnot/GD/lua-5.4.2/lua_web"
CC=gcc
CFLAGS="-g -Wall -L${LUALINUX}/lib -llua -lraylib -lGL -lm -lpthread -ldl -lrt -lX11"
INC="-I${LUALINUX}/include"
INC="-I${LUALINUX}/include -Isrc"
EXEC="egba"
DOBJ="build/linux64/"

Expand Down Expand Up @@ -62,17 +62,20 @@ function comp(){
function link(){
command $TCC $TLINK $TCFLAGS "-o" $TEXEC;
echo $TCC $TLINK $TCFLAGS "-o" $TEXEC;
if [ "$TCC" == "gcc" ] && [ -f $TEXEC ] ;then
command ./$TEXEC;
fi;
}

if [ $# -eq 0 ];then
# default
rm -f $TEXEC;
init "$CC" "$INC" "$CFLAGS" "egba" "$DOBJ";
init "$CC" "$INC" "$CFLAGS" "$EXEC" "$DOBJ";
comp;
link;

elif [ "$1" == "w" ];then
init "$CC2" "$INC2" "$CFLAGS2" "egba.exe" "$DOBJ2";
init "$CC2" "$INC2" "$CFLAGS2" "$EXEC2" "$DOBJ2";
comp;
link;
elif [ "$1" == "web" ];then
Expand Down
Binary file removed new.egba
Binary file not shown.
6 changes: 0 additions & 6 deletions new.lua

This file was deleted.

Binary file removed new.png
Binary file not shown.
5 changes: 0 additions & 5 deletions new1.lua

This file was deleted.

Binary file removed new1.png
Binary file not shown.
Binary file modified save.egba
Binary file not shown.
106 changes: 97 additions & 9 deletions save.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,99 @@
trace("hi")
function EGBA()
cls(0)
spr(0,23,23)
text("aaa",34,6,2,20)
text("a a",124,6,2,20)
if btnp(4) then
text("a&a",124,24,2,20)
end

function collide(x,y,w,h,x2,y2,w2,h2)
if x + w > x2 and
y + h > y2 and
x2 + w2 > x and
y2 + h2 > h then
return true
end
return false
end

function Player(px,py)
local pl = {x=px,y=py,w=16*4,h=16*4}
return pl
end

function Player_draw(player)
rect(player.x,player.y,player.w,player.h,2)
end

function Bullet(px,py)
local bul = {x=px,y=py,w=2,h=10}
return bul
end

function Bullet_draw(bul)
rect(bul.x,bul.y,bul.w,bul.h,19)
end

function BulletManager()
local bulman={}
return bulman
end

function BulletManager_add(bulman,px,py)
local b = Bullet(px,py)
table.insert(bulman,b)
end

function BulletManager_del(bulman,id)
if id>0 and id<=#bulman then
table.remove(bulman, id )
end
end

function BulletManager_collide(bullman,px,py,pw,ph)
for n,v in pairs(bullman) do
if collide(v.x,v.y,v.w,v.h,px,py,pw,ph)==true then
return n
end
end
return 0
end

function BulletManager_draw(bulman)
for n,v in pairs(bulman) do
trace("id "..tostring(n).."x "..tostring(v.x).." y "..tostring(v.y))
Bullet_draw(v)
end
trace("-------------------")
end

local player = Player(23,423)
local bulman = BulletManager()
local timer_btn=0

function EGBA()
-- local x,y,btn1,btn3,btn2 = mouse()
-- player.x = x
-- player.y = y
if btn(2) then
player.x = player.x -3
end
if btn(3) then
player.x = player.x +3
end
BulletManager_del(bulman,
BulletManager_collide(bulman,player.x,player.y,player.w,player.h))
-- player fire
if timer_btn<=0 then
if btn(0) then
BulletManager_add(bulman,player.x+16,player.y-50)
timer_btn=16
end
else
timer_btn=timer_btn-1
end
-- move bullet and destroy
for i=#bulman,1,-1 do
if bulman[i].y < 0 then
table.remove(bulman,i)
else
bulman[i].y = bulman[i].y-2
end
end

Player_draw(player)
BulletManager_draw(bulman)
end
Binary file modified save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 63 additions & 18 deletions src/EGBA.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ struct segba_atlas egba_atlas;

struct sconfig
{
Color color1;
Color color2;
// Color color1;
// Color color2;
int theme_nb;
};

struct suiconfig
Expand All @@ -19,7 +20,7 @@ struct suiconfig
float timer;
};

struct suiconfig _UICONFIG;
struct suiconfig _UICONFIG={0};

char UICONFIG_Timer()
{
Expand All @@ -32,14 +33,15 @@ char UICONFIG_Timer()
_UICONFIG.timer -= GetFrameTime();
return 0;
}
Color UICONFIG_COL1()
{
return _UICONFIG.config.color1;
}
Color UICONFIG_COL2()
{
return _UICONFIG.config.color2;
}
// Color UICONFIG_COL1()
// {
// return _UICONFIG.config.color1;
// }
// Color UICONFIG_COL2()
// {
// return _UICONFIG.config.color2;
// }

char UICONFIG_GetActive()
{
return _UICONFIG.isactive;
Expand All @@ -52,7 +54,15 @@ void UICONFIG_SetActive(char c)
_UICONFIG.timer=0.001f;
// }
}

int UICONFIG_GetTheme()
{
return _UICONFIG.config.theme_nb;
}
void UICONFIG_SetTheme(int itheme)
{
_UICONFIG.config.theme_nb=itheme;
}
/*
void UICONFIG_SetYellowTheme()
{
_UICONFIG.config.color1=(Color){130,145,2};
Expand Down Expand Up @@ -86,7 +96,7 @@ void UICONFIG_SetBlackTheme()
{
_UICONFIG.config.color1=BLACK;
_UICONFIG.config.color2=DARKGRAY;
}
}*/

void UICONFIG_Save()
{
Expand Down Expand Up @@ -224,7 +234,26 @@ void Data_Palette_LoadF(const char* pfile)
if(TextIsEqual(GetFileExtension(pfile),".png"))
{
Image img = LoadImage(pfile);
if(img.width==256 && img.height==257)
if(img.width>=16 && img.width<33 && img.height==1)
{
Color* lcol = LoadImageColors(img);
for(int i=0;i<32;i++)
{
if(i<img.width)
{
egba_data.palettes[egba_data.palette_nb].data[i]=lcol[i];
}
else
{
egba_data.palettes[egba_data.palette_nb].data[i]=(Color){0,0,0,0};
}

}
UnloadImageColors(lcol);
egba_data.palette_nb+=1;
Atlas_UpdatePalette(egba_data.palettes);
}
else if(img.width==256 && img.height==257)
{
for(int i=0;i<EGBA_MAX_PALETTE;i++)
for(int j=0;j<EGBA_MAX_COLOR_PALETTE;j++)
Expand All @@ -240,8 +269,8 @@ void Data_Palette_LoadF(const char* pfile)
{
struct Palette pal = {{0},{BLACK}};
UICONFIG_Load();
pal.data[0]=UICONFIG_COL1();
pal.data[1]=UICONFIG_COL2();
pal.data[0]=WHITE;
pal.data[1]=BLACK;
egba_data.palettes[0]=pal;
egba_data.palette_nb=0;
Atlas_UpdatePalette(egba_data.palettes);
Expand Down Expand Up @@ -359,8 +388,15 @@ struct Sprite Data_Sprite_Get(int id)

void Data_Script_Init()
{
strcpy(egba_data.script,"");
egba_data.script[0]='\0';
}

const char* Data_Script_Get()
{
return TextFormat("%s",egba_data.script);
}

void Data_Script_LoadF(const char* pfile)
{
FILE* fic = fopen(pfile,"r");
Expand Down Expand Up @@ -497,12 +533,21 @@ void Atlas_UpdateSprite(struct Sprite* sprites)
UpdateTexture(egba_atlas.sprites,img.data);
UnloadImage(img);
}

#include "raygui.h"
Color _StyleGetColor(char idcol)
{
int icol=0;
if(idcol==0)
icol = GuiGetStyle(0,1);
else if(idcol==1)
icol = GuiGetStyle(0,2);
return GetColor(icol);
}
void Atlas_DrawPalette(int id, int x, int y, int scale)
{
if(id>-1 && id<6)
{
DrawRectangleLines(x-2,y-2,(32*scale)+4,scale+4,UICONFIG_COL2());
DrawRectangleLines(x-2,y-2,(32*scale)+4,scale+4,_StyleGetColor(1));
DrawTexturePro(egba_atlas.palettes,(Rectangle){0,id,32,1},(Rectangle){x,y,32*scale,scale},(Vector2){0,0},0,WHITE);
}

Expand Down
16 changes: 6 additions & 10 deletions src/EGBA.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include <string.h>
#include "raylib.h"
#define EGBA_VERSION "a1.7"
#define EGBA_TITLE TextFormat("GBA engine ver %s by magnus oblerion",EGBA_VERSION)
#define EGBA_VERSION "a1.7.2"
#define EGBA_TITLE TextFormat("EGBA engine ver %s by magnus oblerion",EGBA_VERSION)

#define EGBA_RUN_NAME "egba"
#define EGBA_EDIT_NAME "egba"
Expand All @@ -18,17 +18,12 @@
#define SAVING_MAX_NUMBER 50
#define SAVING_MAX_STRING 50

// TODO: edit UICONFIG -> raygui
char UICONFIG_Timer();
Color UICONFIG_COL1();
Color UICONFIG_COL2();
char UICONFIG_GetActive();
void UICONFIG_SetActive(char c);
void UICONFIG_SetYellowTheme();
void UICONFIG_SetGreenTheme();
void UICONFIG_SetRedTheme();
void UICONFIG_SetBlueTheme();
void UICONFIG_SetWhiteTheme();
void UICONFIG_SetBlackTheme();
void UICONFIG_SetTheme(int itheme);
int UICONFIG_GetTheme();
void UICONFIG_Save();
void UICONFIG_Load();

Expand Down Expand Up @@ -90,6 +85,7 @@ void Data_Sprite_LoadF(const char *pfile);
void Data_Sprite_LoadD(struct segba_data sdata);
struct Sprite Data_Sprite_Get(int id);
void Data_Script_Init();
const char* Data_Script_Get();
void Data_Script_LoadF(const char* pfile);
void Data_Script_LoadD(struct segba_data sdata);
void Data_Script_Draw(int x,int y,Color color);
Expand Down
Loading

0 comments on commit b1e94d1

Please sign in to comment.