Skip to content

Commit

Permalink
fix entity drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
marekmaskarinec committed Jan 9, 2023
1 parent 83c19f5 commit 282f674
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 24 deletions.
11 changes: 10 additions & 1 deletion compile_flags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
-Ilib/miniaudio
-Ilib/glad
-Ilib/stb
-Ilib/umka/src
-Ilib/rawdraw
-Ilib/rawdraw
-Ilib/chew
-Ilib/umpr
-Wall
-Wextra
-Wno-unused-parameter
-Wno-sign-compare
-Wno-old-style-declaration
-Wno-implicit-fallthroughof
4 changes: 1 addition & 3 deletions examples/platformer/game/player.um
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ fn move() {

if input.isPressed(input.key_left) {
mot.x = -1
body.i.fliph(false)
}

if input.isPressed(input.key_right) {
mot.x = 1
body.i.fliph(true)
}

mot.x *= th.delta * moveSpeed
Expand Down Expand Up @@ -143,7 +141,7 @@ fn handle*() {
if !dying && body.t.p.distanceTo(env.end) < global.tileSize {
signal.emit("finish", null)
}

if colls := body.getColl(env.coins, 1); len(colls) != 0 {
env.coins = delete(env.coins, colls[0].index)
env.score++
Expand Down
15 changes: 7 additions & 8 deletions examples/space-shooter/effects.um
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ fn init*() {
emitters = []particles.Emitter{}
}

fn handle*() {

}
fn handle*() { }

fn damage*() {
dmgEffect.enqueue(
Expand All @@ -30,18 +28,19 @@ fn damage*() {
}

fn enemyDestroy*(pos: th.Vf2) {
const particlec = 2000
e := particles.Emitter{
pos, th.Vf2{0, 0},
th.Vf2{0.1, 0.1}, false, true,

th.Vf2{0, 360},
400, 0,
0.2, 0.2,
1, 0.6, 2,
200, 0.4,
0.4, 0.2,
0.4, 0.2, 2,
0, 0, 0,
[]uint32{0xFFA500ff, 0xe9330caa},
make([]particles.Particle, 200)}
make([]particles.Particle, particlec)}

for i:=0; i < len(e.particles); i++ {
e.particles[i] = particles.Particle{
th.time + std.rand() % 200,
Expand Down
2 changes: 1 addition & 1 deletion examples/space-shooter/hud.um
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ fn draw*() {
s: th.Vf2{1, 1}}, th.white)
}

mainFont.draw(repr(global.score), th.Vf2{1, 1}, th.white, 1.0)
mainFont.draw(repr(global.score), th.Vf2{1, 1}, th.white, 0.2)
}
4 changes: 2 additions & 2 deletions examples/space-shooter/main.um
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"rect.um"
"window.um"
"canvas.um"

"game.um"
"menu.um"
"star.um"
Expand Down Expand Up @@ -34,7 +34,7 @@ fn main() {

for window.cycle() {
canvas.drawRect(0x000022ff, global.cam)

star.handle()
star.draw()

Expand Down
1 change: 1 addition & 0 deletions examples/space-shooter/player.um
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ fn draw*() {
bullets[i].draw(global.cam)
}
}

6 changes: 3 additions & 3 deletions examples/space-shooter/star.um
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const (
starNum = 200
speed = 0.04
speed = 0.01
)

var (
Expand All @@ -24,8 +24,8 @@ fn init*() {
stars[i].y = -std.rand()%round(window.wp.y)
stars[i].x = std.rand()%round(window.wp.x)

stars[i].w = 1
stars[i].h = 2
stars[i].w = 0.1
stars[i].h = 0.2
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void th_ent_draw(th_ent *o, th_rect *camera) {
th_transform t = o->t;
t.pos.x -= camx;
t.pos.y -= camy;

// this logic is incorrect
/*if (q.br.x < 0 || q.br.y < 0)
return;
Expand All @@ -29,10 +29,6 @@ void th_ent_draw(th_ent *o, th_rect *camera) {
if (!o->img) {
th_quad q;
th_transform_rect(&q, t, o->rect);
for (uu i=0; i < 4; i++) {
q.v[i].x *= thg->scaling;
q.v[i].y *= thg->scaling;
}
th_canvas_triangle(o->color, q.v[0], q.v[1], q.v[2]);
th_canvas_triangle(o->color, q.v[0], q.v[2], q.v[3]);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/nav.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void th_navmesh_nav(th_vf2 *cameFrom, th_navmesh *m, th_vf2 p1, th_vf2 p2) {

p1 = vf2_to_loc(m, p1);
p2 = vf2_to_loc(m, p2);

struct qnode *q = push(NULL, p1, NULL, 0);
/*th_vf2 *cameFrom = calloc(sizeof(th_vf2), umkaGetDynArrayLen((void *)&m->d));
for (int i=0; i < umkaGetDynArrayLen((void *)&m->d); ++i) {
Expand Down

0 comments on commit 282f674

Please sign in to comment.