Skip to content

Commit 2e6d6eb

Browse files
committed
Revert "WIP initial cmd removal + drivers"
This reverts commit b3348ab.
1 parent b3348ab commit 2e6d6eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+81
-2812
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# GOOM
22
DOOM engine written in Go
33

4-
![GOOM](/resources/press/goom.png?raw=true "GOOM")
4+
![GOOM](/misc/goom.png?raw=true "GOOM")
55

66
Make sure you have `DOOM1.WAD` in the root dir. Then type `make run` to run GOOM.
77

@@ -10,7 +10,7 @@ Make sure you have `DOOM1.WAD` in the root dir. Then type `make run` to run GOOM
1010
The project is an experiment and is still lacking a lot of
1111
features, such as shooting, enemy behavior, sound, menus, and more.
1212

13-
![DEMO](/resources/press/goom-preview.gif?raw=true "DEMO")
13+
![DEMO](/misc/goom-preview.gif?raw=true "DEMO")
1414

1515
# Development Setup
1616

cmd/doom/internal/game/world.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import (
88
"github.com/go-gl/mathgl/mgl32"
99

1010
"github.com/tinogoehlert/goom"
11-
"github.com/tinogoehlert/goom/utils"
11+
"github.com/tinogoehlert/goom/geometry"
1212
"github.com/tinogoehlert/goom/level"
1313
)
1414

1515
// Wall a DOOM Wall
1616
type Wall struct {
17-
Start utils.Vec2
18-
End utils.Vec2
19-
Normal utils.Vec2
20-
Tangent utils.Vec2
17+
Start geometry.Vec2
18+
End geometry.Vec2
19+
Normal geometry.Vec2
20+
Tangent geometry.Vec2
2121
Length float32
2222
Sides struct {
2323
Right *level.SideDef
@@ -149,7 +149,7 @@ func (w *World) SetPlayer(num int) error {
149149

150150
// Update updates the world (monster think and player position)
151151
func (w *World) Update(t float32) {
152-
ppos := utils.V2(w.me.position[0], w.me.position[1])
152+
ppos := geometry.V2(w.me.position[0], w.me.position[1])
153153
for _, m := range w.monsters {
154154
if !m.IsCorpse() {
155155
m.Update()
@@ -160,14 +160,14 @@ func (w *World) Update(t float32) {
160160
for e := w.projectiles.Front(); e != nil; e = e.Next() {
161161
var (
162162
p = e.Value.(*Projectile)
163-
projPos = utils.V2(p.position[0], p.position[1])
163+
projPos = geometry.V2(p.position[0], p.position[1])
164164
)
165165
for _, m := range w.monsters {
166166
if m.IsCorpse() {
167167
continue
168168
}
169169
if w.hitThing(m, p, m.sizeX, m.sizeY) {
170-
mpos := utils.V2(m.position[0], m.position[1])
170+
mpos := geometry.V2(m.position[0], m.position[1])
171171
dist := ppos.DistanceTo(mpos)
172172
w.projectiles.Remove(e)
173173
m.Hit(p.damage, dist)

cmd/doom/internal/opengl/geometry.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ type glWorldGeometry struct {
1717
seqTime time.Time
1818
}
1919

20-
func addGlWorldutils(dst []*glWorldGeometry, src *glWorldGeometry) []*glWorldGeometry {
20+
func addGlWorldGeometry(dst []*glWorldGeometry, src *glWorldGeometry) []*glWorldGeometry {
2121
if src == nil {
2222
return dst
2323
}
2424
return append(dst, src)
2525
}
2626

27-
func newGlWorldutils(data []float32, light float32, texture []*glTexture) *glWorldGeometry {
27+
func newGlWorldGeometry(data []float32, light float32, texture []*glTexture) *glWorldGeometry {
2828
m := &glWorldGeometry{
2929
data: data,
3030
light: light,

cmd/doom/internal/opengl/level.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package opengl
22

33
import (
44
"github.com/go-gl/gl/v2.1/gl"
5-
"github.com/tinogoehlert/goom/goom"
5+
"github.com/tinogoehlert/goom"
66
"github.com/tinogoehlert/goom/level"
77
)
88

@@ -73,12 +73,12 @@ func (s *subSector) addFlats(md *level.Level, gd *goom.GameData, ts glTextureSto
7373

7474
s.sector = sector
7575
if len(gd.Flat(sector.FloorTexture())) > 0 {
76-
fm := newGlWorldutils(floorData, sector.LightLevel(), ts[sector.FloorTexture()])
77-
s.floors = addGlWorldutils(s.floors, fm)
76+
fm := newGlWorldGeometry(floorData, sector.LightLevel(), ts[sector.FloorTexture()])
77+
s.floors = addGlWorldGeometry(s.floors, fm)
7878
}
7979
if len(gd.Flat(sector.CeilTexture())) > 0 {
80-
cm := newGlWorldutils(ceilData, md.Sectors[side.Sector].LightLevel(), ts[sector.CeilTexture()])
81-
s.ceilings = addGlWorldutils(s.ceilings, cm)
80+
cm := newGlWorldGeometry(ceilData, md.Sectors[side.Sector].LightLevel(), ts[sector.CeilTexture()])
81+
s.ceilings = addGlWorldGeometry(s.ceilings, cm)
8282
}
8383
}
8484

@@ -135,8 +135,8 @@ func (s *subSector) addWalls(md *level.Level, gd *goom.GameData, ts glTextureSto
135135
-start.X(), sector.CeilHeight(), start.Y(), -sLen / tw, height / th,
136136
}
137137
if gd.Texture(side.Upper()) != nil {
138-
wm := newGlWorldutils(wallData, sector.LightLevel(), ts[side.Upper()])
139-
s.walls = addGlWorldutils(s.walls, wm)
138+
wm := newGlWorldGeometry(wallData, sector.LightLevel(), ts[side.Upper()])
139+
s.walls = addGlWorldGeometry(s.walls, wm)
140140
}
141141
}
142142

@@ -159,8 +159,8 @@ func (s *subSector) addWalls(md *level.Level, gd *goom.GameData, ts glTextureSto
159159
-start.X(), sector.FloorHeight(), start.Y(), -sLen / tw, height / th,
160160
}
161161
if gd.Texture(side.Lower()) != nil {
162-
wm := newGlWorldutils(wallData, sector.LightLevel(), ts[side.Lower()])
163-
s.walls = addGlWorldutils(s.walls, wm)
162+
wm := newGlWorldGeometry(wallData, sector.LightLevel(), ts[side.Lower()])
163+
s.walls = addGlWorldGeometry(s.walls, wm)
164164
}
165165
}
166166

@@ -181,8 +181,8 @@ func (s *subSector) addWalls(md *level.Level, gd *goom.GameData, ts glTextureSto
181181
-end.X(), sector.FloorHeight(), end.Y(), -eLen / tw, height / th,
182182
-start.X(), sector.FloorHeight(), start.Y(), -sLen / tw, height / th,
183183
}
184-
wm := newGlWorldutils(wallData, sector.LightLevel(), ts[side.Middle()])
185-
s.walls = addGlWorldutils(s.walls, wm)
184+
wm := newGlWorldGeometry(wallData, sector.LightLevel(), ts[side.Middle()])
185+
s.walls = addGlWorldGeometry(s.walls, wm)
186186
}
187187
}
188188
}

cmd/doom/internal/opengl/renderer.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/go-gl/glfw/v3.2/glfw"
1010
"github.com/go-gl/mathgl/mgl32"
1111

12-
"github.com/tinogoehlert/goom/game"
13-
"github.com/tinogoehlert/goom/goom"
12+
"github.com/tinogoehlert/goom"
13+
"github.com/tinogoehlert/goom/cmd/doom/internal/game"
1414
"github.com/tinogoehlert/goom/graphics"
1515
"github.com/tinogoehlert/goom/level"
1616
)
@@ -285,9 +285,8 @@ func (gr *GLRenderer) Loop(drawCB func(), inputCB func(win *glfw.Window, frameti
285285
targetFrameTime := time.Second / time.Duration(gr.fpsCap)
286286
for !gr.window.ShouldClose() {
287287
t0 := time.Now()
288-
gr.fbWidth = 1024
289-
gr.fbHeight = 768
290-
gl.Viewport(0, 0, 1024, 768)
288+
gr.fbWidth, gr.fbHeight = gr.window.GetFramebufferSize()
289+
gl.Viewport(0, 0, int32(gr.fbWidth), int32(gr.fbHeight))
291290
// Do OpenGL stuff.
292291
gl.Enable(gl.DEPTH_TEST)
293292
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

cmd/doom/main.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ import (
99

1010
"github.com/go-gl/glfw/v3.2/glfw"
1111

12-
"github.com/tinogoehlert/goom/goom"
12+
"github.com/tinogoehlert/goom"
1313
"github.com/tinogoehlert/goom/audio/midi"
14-
"github.com/tinogoehlert/goom/game"
14+
"github.com/tinogoehlert/goom/cmd/doom/internal/game"
1515
"github.com/tinogoehlert/goom/cmd/doom/internal/opengl"
1616
"github.com/tinogoehlert/goom/graphics"
1717
"github.com/tinogoehlert/goom/level"
18-
"github.com/tinogoehlert/goom/utils"
1918
)
2019

2120
var (
2221
shaderDir = "resources/shaders"
23-
log = utils.GoomConsole
22+
log = goom.GoomConsole
2423
)
2524

2625
type renderStats struct {

cmd/maptest/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/faiface/pixel/imdraw"
1313
"github.com/faiface/pixel/pixelgl"
1414
"github.com/tinogoehlert/goom"
15-
"github.com/tinogoehlert/goom/utils"
15+
"github.com/tinogoehlert/goom/geometry"
1616
"github.com/ttacon/chalk"
1717
"golang.org/x/image/colornames"
1818
)
@@ -133,7 +133,7 @@ func run() {
133133
var (
134134
ls = e1m1.Vert(uint32(line.Start)).DivScalar(down)
135135
le = e1m1.Vert(uint32(line.End)).DivScalar(down)
136-
mid = utils.V2((ls.X()+le.X())/2, (ls.Y()+le.Y())/2)
136+
mid = geometry.V2((ls.X()+le.X())/2, (ls.Y()+le.Y())/2)
137137
)
138138

139139
tangent := le.Sub(ls).Normalize()

utils/console.go console.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
package utils
1+
package goom
22

33
import (
44
"fmt"
5-
"os"
65

76
"github.com/ttacon/chalk"
87
)
@@ -38,9 +37,3 @@ func (c *Console) Red(format string, a ...interface{}) {
3837
func (c *Console) Print(format string, a ...interface{}) {
3938
fmt.Println(fmt.Sprintf(format, a...))
4039
}
41-
42-
// Fatalf prints console text in the default color using the given format and values.
43-
func (c *Console) Fatalf(format string, a ...interface{}) {
44-
fmt.Println(c.Redf(format, a...))
45-
os.Exit(2)
46-
}

drivers/audio.go

-4
This file was deleted.

drivers/glfw/glfw.go

-23
This file was deleted.

drivers/glfw/input.go

-45
This file was deleted.

0 commit comments

Comments
 (0)