Skip to content

Commit c89f29c

Browse files
committed
Update
1 parent 6200cb5 commit c89f29c

18 files changed

+167
-128
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Oinkyparty-Client.exe
2-
Oinkyparty-Server.exe
1+
Oinkyparty-Client-Windows.exe
2+
Oinkyparty-Server-Windows.exe
3+
Oinkyparty-Server-Raspberry-Pi
34
.idea

build_raspberry_pi.cmd

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
set GOOS=linux
2-
set GOARCH=arm
1+
@set GOOS=linux
2+
@set GOARCH=arm
33

4-
go build -o="Oinkyparty-Client.exe" ./cmd/client
5-
go build -o="Oinkyparty-Server.exe" ./cmd/server
4+
go build -o="Oinkyparty-Server-Raspberry-Pi" ./cmd/server

build_windows.cmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
set GOOS=windows
2-
set GOARCH=amd64
1+
@set GOOS=windows
2+
@set GOARCH=amd64
33

4-
go build -o="Oinkyparty-Client.exe" ./cmd/client
5-
go build -o="Oinkyparty-Server.exe" ./cmd/server
4+
go build -o="Oinkyparty-Client-Windows.exe" ./cmd/client
5+
go build -o="Oinkyparty-Server-Windows.exe" ./cmd/server

client/client.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"github.com/Lama06/Oinky-Party/client/flappybird"
7+
"github.com/Lama06/Oinky-Party/client/flappyoinky"
88
"github.com/Lama06/Oinky-Party/client/game"
99
"github.com/Lama06/Oinky-Party/protocol"
1010
"github.com/hajimehoshi/ebiten/v2"
@@ -21,9 +21,9 @@ type gameType struct {
2121

2222
var gameTypes = []gameType{
2323
{
24-
name: "flappybird",
25-
displayName: "Flappy Bird",
26-
creator: flappybird.Create,
24+
name: "flappyoinky",
25+
displayName: "Flappy Oinky",
26+
creator: flappyoinky.Create,
2727
},
2828
}
2929

@@ -67,9 +67,8 @@ func newClient() *client {
6767
}
6868

6969
func (c *client) start() {
70-
fmt.Println("client starting...")
71-
7270
log.SetFlags(log.Lshortfile | log.Ltime)
71+
log.Println("client starting...")
7372

7473
err := c.connect()
7574
if err != nil {
@@ -309,8 +308,8 @@ func (c *client) handlePacket(packet []byte) error {
309308
c.currentGame = nil
310309
c.currentScreen = newPartyScreen(c)
311310
default:
312-
if packetHandlerComponent, ok := c.currentScreen.(packetHandlerScreen); ok {
313-
err := packetHandlerComponent.HandlePacket(packet)
311+
if packetHandlerScreen, ok := c.currentScreen.(packetHandlerScreen); ok {
312+
err := packetHandlerScreen.HandlePacket(packet)
314313
if err != nil {
315314
return fmt.Errorf("screen failed to handle error: %w", err)
316315
}

client/flappybird/flappybird.go client/flappyoinky/flappyoinky.go

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package flappybird
1+
package flappyoinky
22

33
import (
44
"bytes"
@@ -8,7 +8,7 @@ import (
88
"github.com/Lama06/Oinky-Party/client/game"
99
"github.com/Lama06/Oinky-Party/client/rescources"
1010
"github.com/Lama06/Oinky-Party/client/ui"
11-
shared "github.com/Lama06/Oinky-Party/flappybird"
11+
shared "github.com/Lama06/Oinky-Party/flappyoinky"
1212
"github.com/Lama06/Oinky-Party/protocol"
1313
"github.com/hajimehoshi/ebiten/v2"
1414
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
@@ -23,9 +23,9 @@ import (
2323
)
2424

2525
var (
26-
//go:embed bird.png
27-
birdImageData []byte
28-
birdImage = loadImage(birdImageData)
26+
//go:embed oinky.png
27+
oinkyImageData []byte
28+
oinkyImage = loadImage(oinkyImageData)
2929
)
3030

3131
func loadImage(data []byte) image.Image {
@@ -37,12 +37,12 @@ func loadImage(data []byte) image.Image {
3737
}
3838

3939
// Die Größe des Vogels wird anhand der Größe des Fensters zu einem Quadrat ergänzt.
40-
func getVisualBirdSize() int {
40+
func getVisualOinkySize() int {
4141
windowWidth, windowHeight := ebiten.WindowSize()
4242
if windowWidth >= windowHeight {
43-
return int(shared.BirdSize * float64(windowWidth))
43+
return int(shared.OinkySize * float64(windowWidth))
4444
} else {
45-
return int(shared.BirdSize * float64(windowHeight))
45+
return int(shared.OinkySize * float64(windowHeight))
4646
}
4747
}
4848

@@ -62,7 +62,7 @@ func (p *player) clientTick(delta float64) {
6262

6363
skippedTicks := int(math.Trunc(delta))
6464
for i := 1; i <= skippedTicks; i++ {
65-
speedY += shared.BirdSpeedYIncreasePerTick
65+
speedY += shared.OinkySpeedYIncreasePerTick
6666
posY += speedY
6767
}
6868
remainingDelta := delta - float64(skippedTicks)
@@ -91,16 +91,16 @@ func (p *player) clientTick(delta float64) {
9191

9292
func (p *player) draw(client game.Client, screen *ebiten.Image) {
9393
windowWidth, windowHeight := ebiten.WindowSize()
94-
img := ebiten.NewImageFromImage(birdImage)
94+
img := ebiten.NewImageFromImage(oinkyImage)
9595
imgWidth, imgHeight := img.Size()
96-
birdSize := getVisualBirdSize()
97-
birdXScale, birdYScale := float64(birdSize)/float64(imgWidth), float64(birdSize)/float64(imgHeight)
98-
birdX, birdY := shared.BirdPosX*float64(windowWidth), p.clientPosY*float64(windowHeight)
96+
oinkySize := getVisualOinkySize()
97+
oinkyXScale, oinkyYScale := float64(oinkySize)/float64(imgWidth), float64(oinkySize)/float64(imgHeight)
98+
oinkyX, oinkyY := shared.OinkyPosX*float64(windowWidth), p.clientPosY*float64(windowHeight)
9999

100100
var drawOptions ebiten.DrawImageOptions
101101
drawOptions.GeoM.Rotate(p.rotation)
102-
drawOptions.GeoM.Scale(birdXScale, birdYScale)
103-
drawOptions.GeoM.Translate(birdX, birdY)
102+
drawOptions.GeoM.Scale(oinkyXScale, oinkyYScale)
103+
drawOptions.GeoM.Translate(oinkyX, oinkyY)
104104
screen.DrawImage(img, &drawOptions)
105105

106106
if p.id != client.Id() {
@@ -112,7 +112,7 @@ func (p *player) draw(client game.Client, screen *ebiten.Image) {
112112
}
113113
}
114114

115-
textX, textY := birdX+float64(birdSize)+50, birdY+float64(birdSize)/2
115+
textX, textY := oinkyX+float64(oinkySize)+50, oinkyY+float64(oinkySize)/2
116116
text.Draw(screen, partyPlayer.Name, rescources.RobotoNormalFont, int(textX), int(textY), colornames.Black)
117117
}
118118
}
@@ -174,8 +174,8 @@ func (i *impl) HandleGameStarted() {
174174
for index, partyPlayer := range partyPlayers {
175175
i.players[index] = &player{
176176
id: partyPlayer.Id,
177-
serverPosY: shared.BirdStartPosY,
178-
clientPosY: shared.BirdStartPosY,
177+
serverPosY: shared.OinkyStartPosY,
178+
clientPosY: shared.OinkyStartPosY,
179179
serverSpeedY: 0,
180180
clientSpeedY: 0,
181181
rotation: 0,
@@ -239,7 +239,9 @@ func (i *impl) HandlePacket(packet []byte) error {
239239
func (i *impl) obstacleCounter() *ui.Text {
240240
windowWidth, _ := ebiten.WindowSize()
241241

242-
return ui.NewText(ui.NewCenteredPosition(windowWidth/2, 50), strconv.Itoa(int(i.obstacleCount)), rescources.RobotoTitleFont)
242+
return ui.NewText(ui.NewCenteredPosition(windowWidth/2, 50), strconv.Itoa(int(i.obstacleCount)), ui.TextColorPalette{
243+
Color: colornames.Black,
244+
}, rescources.RobotoTitleFont)
243245
}
244246

245247
func (i *impl) Draw(screen *ebiten.Image) {
File renamed without changes.
File renamed without changes.

client/rescources/fonts.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
var (
11-
//go:embed roboto_thin.ttf
11+
//go:embed roboto_bold.ttf
1212
robotoFontData []byte
1313
RobotoNormalFont font.Face
1414
RobotoTitleFont font.Face
@@ -23,7 +23,7 @@ func init() {
2323
}
2424

2525
RobotoNormalFont, err = opentype.NewFace(robotoFont, &opentype.FaceOptions{
26-
Size: 24,
26+
Size: 28,
2727
DPI: 72,
2828
Hinting: font.HintingFull,
2929
})
@@ -32,7 +32,7 @@ func init() {
3232
}
3333

3434
RobotoTitleFont, err = opentype.NewFace(robotoFont, &opentype.FaceOptions{
35-
Size: 55,
35+
Size: 70,
3636
DPI: 72,
3737
Hinting: font.HintingFull,
3838
})

client/rescources/roboto_bold.ttf

163 KB
Binary file not shown.

client/rescources/roboto_thin.ttf

-165 KB
Binary file not shown.

client/screen.go

+38-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ import (
88
"github.com/Lama06/Oinky-Party/protocol"
99
"github.com/hajimehoshi/ebiten/v2"
1010
"github.com/hajimehoshi/ebiten/v2/inpututil"
11+
"image/color"
12+
)
13+
14+
var (
15+
defaultBackgroundColor = color.RGBA{R: 255, G: 255, B: 255, A: 255}
16+
defaultButtonColors = ui.ButtonColorPalette{
17+
BackgroundColor: color.RGBA{R: 18, G: 53, B: 91, A: 255},
18+
BackgroundHoverColor: color.RGBA{R: 134, G: 22, B: 87, A: 255},
19+
TextColor: color.RGBA{R: 212, G: 245, B: 245, A: 255},
20+
TextHoverColor: color.RGBA{R: 212, G: 245, B: 245, A: 255},
21+
}
22+
defaultTextColors = ui.TextColorPalette{
23+
Color: color.RGBA{R: 87, G: 70, B: 123, A: 255},
24+
HoverColor: color.RGBA{R: 82, G: 73, B: 72, A: 255},
25+
}
26+
defaultTitleColors = ui.TextColorPalette{
27+
Color: color.RGBA{R: 87, G: 70, B: 123, A: 255},
28+
HoverColor: color.RGBA{R: 112, G: 248, B: 186, A: 255},
29+
}
1130
)
1231

1332
type screen interface {
@@ -35,21 +54,21 @@ func newTitleScreen(c *client) *titleScreen {
3554
func (t *titleScreen) title() *ui.Text {
3655
width, height := ebiten.WindowSize()
3756

38-
return ui.NewText(ui.NewCenteredPosition(width/2, (height/3)), "Oinky Party", rescources.RobotoTitleFont)
57+
return ui.NewText(ui.NewCenteredPosition(width/2, height/3), "Oinky Party", defaultTitleColors, rescources.RobotoTitleFont)
3958
}
4059

4160
func (t *titleScreen) createPartyButton() *ui.Button {
4261
width, height := ebiten.WindowSize()
4362

44-
return ui.NewButton(ui.NewCenteredPosition(width/2, (height/3)*2), "Party erstellen", func() {
63+
return ui.NewButton(ui.NewCenteredPosition(width/2, (height/3)*2), "Party erstellen", defaultButtonColors, func() {
4564
t.c.currentScreen = newCreatePartyScreen(t.c)
4665
})
4766
}
4867

4968
func (t *titleScreen) joinPartyBtn() *ui.Button {
5069
width, height := ebiten.WindowSize()
5170

52-
return ui.NewButton(ui.NewCenteredPosition(width/2, (height/3)*2+100), "Party beitreten", func() {
71+
return ui.NewButton(ui.NewCenteredPosition(width/2, (height/3)*2+100), "Party beitreten", defaultButtonColors, func() {
5372
t.c.currentScreen = newJoinPartyScreen(t.c)
5473
})
5574
}
@@ -71,6 +90,7 @@ func (t *titleScreen) Update() {
7190
}
7291

7392
func (t *titleScreen) Draw(screen *ebiten.Image) {
93+
screen.Fill(defaultBackgroundColor)
7494
for _, component := range t.content() {
7595
component.Draw(screen)
7696
}
@@ -105,6 +125,7 @@ func (s *gameScreen) Update() {
105125
}
106126

107127
func (s *gameScreen) Draw(screen *ebiten.Image) {
128+
screen.Fill(defaultBackgroundColor)
108129
if s.c.currentGame != nil {
109130
s.c.currentGame.Draw(screen)
110131
}
@@ -151,13 +172,13 @@ func (j *joinPartyScreen) statusText() *ui.Text {
151172
text = "Fehler beim Laden der Parties"
152173
}
153174

154-
return ui.NewText(ui.NewCenteredPosition(windowWidth/2, windowHeight/2), text, rescources.RobotoNormalFont)
175+
return ui.NewText(ui.NewCenteredPosition(windowWidth/2, windowHeight/2), text, defaultTextColors, rescources.RobotoNormalFont)
155176
}
156177

157178
func (j *joinPartyScreen) title() *ui.Text {
158179
windowWidth, windowHeight := ebiten.WindowSize()
159180

160-
return ui.NewText(ui.NewCenteredPosition(windowWidth/2, windowHeight/3), "Party beitreten", rescources.RobotoTitleFont)
181+
return ui.NewText(ui.NewCenteredPosition(windowWidth/2, windowHeight/3), "Party beitreten", defaultTitleColors, rescources.RobotoTitleFont)
161182
}
162183

163184
func (j *joinPartyScreen) partiesList() []*ui.Button {
@@ -170,7 +191,7 @@ func (j *joinPartyScreen) partiesList() []*ui.Button {
170191
partyButton := ui.NewButton(ui.NewCenteredPosition(
171192
windowWidth/2,
172193
(windowHeight/3)*2+100*i,
173-
), fmt.Sprintf("%s (%d Spieler)", party.Name, len(party.Players)), func() {
194+
), fmt.Sprintf("%s (%d Spieler)", party.Name, len(party.Players)), defaultButtonColors, func() {
174195
joinParty, err := json.Marshal(protocol.JoinPartyPacket{
175196
PacketName: protocol.JoinPartyPacketName,
176197
Id: partyCopy.Id,
@@ -210,6 +231,7 @@ func (j *joinPartyScreen) Update() {
210231
}
211232

212233
func (j *joinPartyScreen) Draw(screen *ebiten.Image) {
234+
screen.Fill(defaultBackgroundColor)
213235
for _, component := range j.content() {
214236
component.Draw(screen)
215237
}
@@ -256,7 +278,7 @@ func (c *createPartyScreen) partyNameText() *ui.Text {
256278

257279
pos := ui.NewCenteredPosition(width/2, height/3)
258280

259-
return ui.NewText(pos, "Name der Party: "+string(c.partyName), rescources.RobotoNormalFont)
281+
return ui.NewText(pos, "Name der Party: "+string(c.partyName), defaultTitleColors, rescources.RobotoTitleFont)
260282
}
261283

262284
func (c *createPartyScreen) createButton() *ui.Button {
@@ -275,7 +297,7 @@ func (c *createPartyScreen) createButton() *ui.Button {
275297
c.c.SendPacket(createParty)
276298
}
277299

278-
return ui.NewButton(pos, "Party erstellen", callback)
300+
return ui.NewButton(pos, "Party erstellen", defaultButtonColors, callback)
279301
}
280302

281303
func (c *createPartyScreen) Update() {
@@ -292,6 +314,7 @@ func (c *createPartyScreen) Update() {
292314
}
293315

294316
func (c *createPartyScreen) Draw(screen *ebiten.Image) {
317+
screen.Fill(defaultBackgroundColor)
295318
c.partyNameText().Draw(screen)
296319
c.createButton().Draw(screen)
297320
}
@@ -313,7 +336,7 @@ func (p *partyScreen) title() *ui.Text {
313336

314337
pos := ui.NewCenteredPosition(width/2, height/3)
315338

316-
return ui.NewText(pos, "Party: "+p.c.partyName, rescources.RobotoTitleFont)
339+
return ui.NewText(pos, "Party: "+p.c.partyName, defaultTitleColors, rescources.RobotoTitleFont)
317340
}
318341

319342
func (p *partyScreen) playerList() []*ui.Text {
@@ -324,7 +347,7 @@ func (p *partyScreen) playerList() []*ui.Text {
324347
playerList = append(playerList, ui.NewText(ui.NewCenteredPosition(
325348
windowWidth/2,
326349
100+windowHeight/3+100*i,
327-
), player.Name, rescources.RobotoNormalFont))
350+
), player.Name, defaultTextColors, rescources.RobotoNormalFont))
328351
}
329352

330353
return playerList
@@ -335,7 +358,7 @@ func (p *partyScreen) startGameButton() *ui.Button {
335358

336359
pos := ui.NewCenteredPosition(windowWidth/2, windowHeight-100)
337360

338-
return ui.NewButton(pos, "Spiel starten", func() {
361+
return ui.NewButton(pos, "Spiel starten", defaultButtonColors, func() {
339362
p.c.currentScreen = newStartGameScreen(p.c)
340363
})
341364
}
@@ -368,6 +391,7 @@ func (p *partyScreen) Update() {
368391
}
369392

370393
func (p *partyScreen) Draw(screen *ebiten.Image) {
394+
screen.Fill(defaultBackgroundColor)
371395
for _, component := range p.contents() {
372396
component.Draw(screen)
373397
}
@@ -390,7 +414,7 @@ func (s *startGameScreen) title() *ui.Text {
390414

391415
pos := ui.NewCenteredPosition(width/2, height/3)
392416

393-
return ui.NewText(pos, "Spiel starten", rescources.RobotoTitleFont)
417+
return ui.NewText(pos, "Spiel starten", defaultTextColors, rescources.RobotoTitleFont)
394418
}
395419

396420
func (s *startGameScreen) gameButtons() []*ui.Button {
@@ -411,7 +435,7 @@ func (s *startGameScreen) gameButtons() []*ui.Button {
411435
s.c.SendPacket(startGame)
412436
}
413437

414-
buttons = append(buttons, ui.NewButton(pos, gameType.displayName, callback))
438+
buttons = append(buttons, ui.NewButton(pos, gameType.displayName, defaultButtonColors, callback))
415439
}
416440

417441
return buttons
@@ -439,6 +463,7 @@ func (s *startGameScreen) Update() {
439463
}
440464

441465
func (s *startGameScreen) Draw(screen *ebiten.Image) {
466+
screen.Fill(defaultBackgroundColor)
442467
for _, component := range s.content() {
443468
component.Draw(screen)
444469
}

0 commit comments

Comments
 (0)