Skip to content

Commit

Permalink
Merge branch 'main' of github.com:tophat2d/tophat
Browse files Browse the repository at this point in the history
  • Loading branch information
marekmaskarinec committed Sep 24, 2024
2 parents 220164e + 8c0fd57 commit 7be82b1
Show file tree
Hide file tree
Showing 24 changed files with 698 additions and 365 deletions.
6 changes: 2 additions & 4 deletions demos/flappy/main.um
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ const (
)

// The different frames for the bird
const (
BirdAnimJump = th::Vf2{ 0, 0 }
BirdAnimFall = th::Vf2{ 1, 0 }
)
BirdAnimJump := th::Vf2{ 0, 0 }
BirdAnimFall := th::Vf2{ 1, 0 }

var (
// atlas containing the bird textures
Expand Down
9 changes: 4 additions & 5 deletions demos/pomodoro/main.um
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,16 @@ type (
}
)

const (
c_colorschemeDark = Colorscheme{item: 0x565758FF, itemHovered: 0x727475FF, text: 0xFFFFFFFF, background: 0x202122FF, current: 0x4ffa7aFF}
c_colorschemeLight = Colorscheme{item: 0xd7d7d7FF, itemHovered: 0xC4C4C4FF, text: 0x000000FF, background: 0xEEEEEFFF, current: 0x178c35FF}
)
c_colorschemeDark := Colorscheme{item: 0x565758FF, itemHovered: 0x727475FF, text: 0xFFFFFFFF, background: 0x202122FF, current: 0x4ffa7aFF}
c_colorschemeLight := Colorscheme{item: 0xd7d7d7FF, itemHovered: 0xC4C4C4FF, text: 0x000000FF, background: 0xEEEEEFFF, current: 0x178c35FF}

var (
v_mainFont: th_font::Font
v_mainFontSmall: th_font::Font
v_rectBase: th_image::Image

isDark: bool = true
v_colorscheme: Colorscheme = c_colorschemeDark
v_colorscheme: Colorscheme
v_lastTime: int
v_countdown: Countdown
v_countdownNumber: int
Expand Down Expand Up @@ -490,6 +488,7 @@ const onFrame = fn(args: []any) {
fn init*() {
var err: std::Err

v_colorscheme = c_colorschemeDark
v_lastTime = th::time
th_window::setup("Pomodoro", trunc(screen.w), trunc(screen.h))
th_window::setViewport(th::Vf2{screen.w, screen.h})
Expand Down
2 changes: 1 addition & 1 deletion demos/space-shooter/enemy.um
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type Enemy* = struct {
ent: ent::Ent
}

speed := th::Vf2{0.015, 0.04}
const (
speed = th::Vf2{0.015, 0.04}
maxEnemies = 4
)

Expand Down
2 changes: 1 addition & 1 deletion demos/space-shooter/hud.um
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn init*() {
hearth, err = image::load("gfx/hearth.png")
std::exitif(err)

mainFont, err = font::load("gfx/marediv-regular.ttf", 64, font::Filter.nearest)
mainFont, err = font::load("gfx/marediv-regular.ttf", 64, .nearest)
std::exitif(err)
}

Expand Down
20 changes: 11 additions & 9 deletions demos/tetris/field.um
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ const (

FieldWidth* = 10
FieldHeight* = 22
Colors* = [8]int{
/*None*/ 0x000000FF,
/*Red*/ 0xFF0000FF,
/*Green*/ 0x00FF00FF,
/*Blue*/ 0x0000FFFF,
/*Yellow*/0xFFFF00FF,
/*Purple*/0xFF00FFFF,
/*Orange*/0xFF9900FF,
/*Cyan*/ 0x00CCFFFF}
)

colors* := [8]int{
/*None*/ 0x000000FF,
/*Red*/ 0xFF0000FF,
/*Green*/ 0x00FF00FF,
/*Blue*/ 0x0000FFFF,
/*Yellow*/0xFFFF00FF,
/*Purple*/0xFF00FFFF,
/*Orange*/0xFF9900FF,
/*Cyan*/ 0x00CCFFFF}


var (
lost*: bool
playfield*: [FieldWidth][FieldHeight]int
Expand Down
17 changes: 5 additions & 12 deletions demos/tetris/fx.um
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ import (
"crazytext.um"
)

const (
reference_frame = rect::Rect{
0, 0,
field::FieldWidth*16+6*16,
field::FieldHeight*16 }

EffectClearRow = 0
)
reference_frame := rect::Rect{ 0, 0, field::FieldWidth*16+6*16, field::FieldHeight*16 }
const EffectClearRow = 0

type Effect = struct {
kind: int
life: real

int_data: int
}

Expand Down Expand Up @@ -95,14 +88,14 @@ fn drawCell(c: uint32, r: rect::Rect) {
}

fn cellRec(x, y: int) {
drawCell(field::Colors[field::playfield[x][y]], rect::Rect { offset_x + x * 16, offset_y + y * 16, 15, 15 })
drawCell(field::colors[field::playfield[x][y]], rect::Rect { offset_x + x * 16, offset_y + y * 16, 15, 15 })
}

fn drawPiece(it: piece::Piece, x, y: int, mask: int) {
x_origin := x
for _, chr in it.data {
if chr == '#' {
drawCell(field::Colors[it.color] & mask, rect::Rect { x, y, 15, 15 })
drawCell(field::colors[it.color] & mask, rect::Rect { x, y, 15, 15 })
}
x += 16
if chr == '\n' {
Expand All @@ -116,7 +109,7 @@ fn drawStash() {
canvas::drawRect(0xFFFFFF11, rect::Rect {16*11-1+offset_x, 1*16-1+offset_y, 16*4+1, 16*4+1})
for i := 0; i < 4; i += 1 {
for j := 0; j < 4; j += 1 {
drawCell(field::Colors[field::None], rect::Rect{ (11+i)*16+offset_x, (1+j)*16+offset_y, 15, 15 })
drawCell(field::colors[field::None], rect::Rect{ (11+i)*16+offset_x, (1+j)*16+offset_y, 15, 15 })
}
}
if gameplay::stash < 0 {
Expand Down
Loading

0 comments on commit 7be82b1

Please sign in to comment.