Compare commits
No commits in common. "db90d6bd030ba4d6fd35af4f85db7a3281d4436a" and "21502a58546ecffb25584f7b5bd1c9c86bf8c49d" have entirely different histories.
db90d6bd03
...
21502a5854
7 changed files with 1 additions and 86 deletions
|
@ -9,19 +9,14 @@ import std.format;
|
|||
import std.conv : to;
|
||||
import core.time;
|
||||
import toki.symbols;
|
||||
import world;
|
||||
|
||||
|
||||
extern(C) __gshared string[] rt_options = [ "gcopt=initReserve:128 minPoolSize:256 parallel:2 profile:1" ];
|
||||
|
||||
int main(string[] args) {
|
||||
try {
|
||||
worldContents = new WorldObjectList;
|
||||
InitWindow(800,600,"Unnamed project");
|
||||
log(LogLevel.INFOHIGH, "Window Initialized...");
|
||||
Screen.x = Screen.y = 0;
|
||||
Screen.width = Screen.px_width = 800;
|
||||
Screen.height = Screen.px_height = 600;
|
||||
log(LogLevel.INFOHIGH, "Readying the engine...");
|
||||
GrEngine engine = new GrEngine();
|
||||
auto grstd = grLoadStdLibrary();
|
||||
|
@ -42,6 +37,7 @@ int main(string[] args) {
|
|||
engine.load(bytecode);
|
||||
log(LogLevel.INFOHIGH, "Go Hot Dog, Go...");
|
||||
engine.process();
|
||||
Toki[] p = convert("toki pona");
|
||||
|
||||
auto reference = MonoTime.currTime();
|
||||
auto deltaTime = 1f/60f;
|
||||
|
@ -59,12 +55,6 @@ int main(string[] args) {
|
|||
log(LogLevel.INFOLOW, "Render start...");
|
||||
BeginDrawing();{
|
||||
ClearBackground(Colors.WHITE);
|
||||
|
||||
foreach (obj; worldContents)
|
||||
{
|
||||
obj.render(deltaTime);
|
||||
}
|
||||
|
||||
DrawFPS(0,0);
|
||||
auto pos = GetMousePosition();
|
||||
DrawText(toStringz(format("%f, %f", pos.x, pos.y)), 0, 24, 20, Colors.GREEN);
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
module utils.shapes;
|
||||
|
||||
public struct Vec2f {
|
||||
float x,y;
|
||||
}
|
||||
|
||||
public struct Rectf {
|
||||
float x, y;
|
||||
float width, height;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
module world.entity;
|
||||
|
||||
import world.world_object;
|
||||
|
||||
class Entity : WorldObject {
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
module world;
|
||||
|
||||
public {
|
||||
import world.world_object;
|
||||
import world.entity;
|
||||
import world.rigid;
|
||||
import world.screen;
|
||||
|
||||
WorldObjectList worldContents;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
module world.rigid;
|
||||
|
||||
import world.world_object;
|
||||
import world.screen;
|
||||
import raylib;
|
||||
import std.conv;
|
||||
|
||||
class Rigid : WorldObject {
|
||||
Texture2D sprite;
|
||||
|
||||
override void render(float) {
|
||||
if(IsTextureReady(sprite)){
|
||||
// Get position
|
||||
int drawX = to!int(Screen.px_width*(position.x + hitbox.x - Screen.x)/Screen.width);
|
||||
int drawY = to!int(Screen.px_height*(position.y + hitbox.y - Screen.y)/Screen.height);
|
||||
float scale = Screen.px_height/Screen.height;
|
||||
|
||||
// Culling
|
||||
if(drawX > Screen.width || drawX + sprite.width*scale < 0) return;
|
||||
if(drawY > Screen.height || drawY + sprite.height*scale < 0) return;
|
||||
|
||||
DrawTextureEx(sprite, Vector2(drawX, drawY), 0, scale, Colors.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
module world.screen;
|
||||
|
||||
public ScreenT Screen;
|
||||
|
||||
struct ScreenT {
|
||||
float x,y;
|
||||
float width, height;
|
||||
int px_width, px_height;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
module world.world_object;
|
||||
|
||||
import utils.shapes;
|
||||
import utils.indexedarray;
|
||||
|
||||
alias WorldObjectList = IndexedArray!(WorldObject, 1<<15);
|
||||
|
||||
class WorldObject {
|
||||
public Vec2f position;
|
||||
public Rectf hitbox;
|
||||
|
||||
abstract void update(float deltaTime);
|
||||
abstract void render(float deltaTime);
|
||||
}
|
Reference in a new issue