Skip to content

Commit

Permalink
Removed AngelScript, added dynamic font scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Oct 29, 2021
1 parent 02687d9 commit 70ca542
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 695 deletions.
1 change: 0 additions & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependency "bindbc-openal" version="~>0.4.1"
dependency "imagefmt" version="~>2.1.0"
dependency "dcontain" version="~>1.0.3"
dependency "bindbc-freetype" version="~>0.9.1"
dependency "dangel" version="~>0.7.0"
dependency "sharpevents" version="~>2.0.0"
dependency "bindbc-sdl" version="~>0.19.2"
dependency "asdf" version="~>0.7.5"
Expand Down
12 changes: 6 additions & 6 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import game;
int main() {

// Set the function pointers
gameInit = &_init;
gameUpdate = &_update;
gameCleanup = &_cleanup;
gameBorder = &_border;
gamePostUpdate = &_postUpdate;
kmInit = &_init;
kmUpdate = &_update;
kmCleanup = &_cleanup;
kmBorder = &_border;
kmPostUpdate = &_postUpdate;

// Init engine start the game and then close the engine once the game quits
initEngine();
startGame(vec2i(1920, 1080));
startGame(vec2i(1920/2, 1080/2));
closeEngine();
return 0;
}
10 changes: 6 additions & 4 deletions source/engine/game.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ void startGame(vec2i viewportSize = vec2i(1920, 1080)) {

// Fixed timestep updates
float tTimeAcc = 0;
while(timeAccumulator >= KM_TIMESTEP && tTimeAcc < KM_MAX_TIMESTEP) {
timeAccumulator -= KM_TIMESTEP;
tTimeAcc += KM_TIMESTEP;
kmFixedUpdate();
if (kmFixedUpdate) {
while(timeAccumulator >= KM_TIMESTEP && tTimeAcc < KM_MAX_TIMESTEP) {
timeAccumulator -= KM_TIMESTEP;
tTimeAcc += KM_TIMESTEP;
kmFixedUpdate();
}
}

// Unbind our framebuffer
Expand Down
1 change: 0 additions & 1 deletion source/engine/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public import engine.net;
public import engine.ui;
public import engine.game;
public import engine.i18n;
public import engine.scripting;

import bindbc.sdl;
import bindbc.openal;
Expand Down
17 changes: 12 additions & 5 deletions source/engine/render/texture/font.d
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void initFontSystem() {

// The game's font
GameFonts["KosugiMaru"] = new Font("Kosugi Maru", cast(ubyte[])import("fonts/KosugiMaru.ttf"), 24);
GameFonts["PixelMPlus10"] = new Font("PixelM+ 10", cast(ubyte[])import("fonts/PixelMPlus10.ttf"), 24);
GameFonts["PixelMPlus10"] = new Font("PixelM+ 10", cast(ubyte[])import("fonts/PixelMPlus10.ttf"), 10);

kmSwitchFont("PixelMPlus10");
}
Expand Down Expand Up @@ -147,6 +147,7 @@ private:
Texture fontTexture;
Glyph[GlyphIndex] glyphs;
int size;
float scale = 1;
bool hasVertical;

string name;
Expand Down Expand Up @@ -311,11 +312,15 @@ public:
if (size == this.size) return;

// Set the size of the font
FT_Set_Pixel_Sizes(fontFace, 0, size);
FT_Set_Pixel_Sizes(fontFace, size, 0);
metrics = vec2(size, fontFace.size.metrics.height >> 6);
this.size = size;
}

final void setScale(float scale=1) {
this.scale = scale;
}

/**
Gets the advance of a glyph
*/
Expand All @@ -330,7 +335,7 @@ public:
if (idx !in glyphs) enforce(genGlyphFor(glyph), "Could not find glyph for character %s".format(glyph));

// Return the advance of the glyphs
return glyphs[idx].advance;
return glyphs[idx].advance*scale;
}

/**
Expand Down Expand Up @@ -366,7 +371,7 @@ public:
if (curLineLen > size.x) size.x = curLineLen;
}
size.y = metrics.y*lines;
return size;
return size*scale;
}


Expand Down Expand Up @@ -492,13 +497,15 @@ public:
(position.y - bearing.y)+metrics.y
);

pos *= scale;

mat4 transform =
mat4.translation(-origin.x, -origin.y, 0) *
mat4.translation(pos.x, pos.y, 0) *
mat4.translation(origin.x, origin.y, 0) *
mat4.zrotation(rotation) *
mat4.translation(-origin.x, -origin.y, 0) *
mat4.scaling(area.z, area.w, 0);
mat4.scaling(area.z*scale, area.w*scale, 0);


vec4 uvArea = vec4(
Expand Down
30 changes: 0 additions & 30 deletions source/engine/scripting/package.d

This file was deleted.

162 changes: 0 additions & 162 deletions source/engine/scripting/script.d

This file was deleted.

Loading

0 comments on commit 70ca542

Please sign in to comment.