Skip to content

Commit

Permalink
Level editor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgraybill committed Apr 9, 2022
1 parent 0152bf1 commit 7613dae
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ Currently in very preliminary state. Builds and runs on Windows, *theoretically*
![screenshot](https://github.com/jcgraybill/it-costs-money/blob/main/screenshot.png)

Built in [golang](https://go.dev/) using the [ebiten](https://ebiten.org/) 2D game library. Tileset thanks to [ludicarts](https://ludicarts.itch.io/) *[license](https://www.ludicarts.com/license-2/)*, sounds [GameDev Market](https://www.gamedevmarket.net/) *[license](https://static.gamedevmarket.net/terms-conditions/#pro-licence)*, little running guy yoinked from the [ebiten animation demo](https://ebiten.org/examples/animation.html) (thanks!).

# Running the game
```
git clone [email protected]:jcgraybill/it-costs-money.git
go mod tidy
go build -tags "ebitensinglethread deploy"
```
8 changes: 8 additions & 0 deletions deploy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build deploy
// +build deploy

package main

func levelEditor() {
return
}
4 changes: 1 addition & 3 deletions gameloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ func (g *Game) Update() error {

message = fmt.Sprintf("Gather coins and bring them to the green chest.\nIt costs money to be alive!\nYour coins: %d", player.coins)

if editMode {
levelEditor()
}
levelEditor()

return nil
}
10 changes: 4 additions & 6 deletions globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ const (
gravity = 0.5
jumpRecovery = 40
wileECoyoteFrames = 16
editMode = false

screenWidth = 1024
screenHeight = 512
frameWidth = 64
frameHeight = 64
screenWidth = 1024
screenHeight = 512
frameWidth = 64
frameHeight = 64

sampleRate = 48000
)
Expand Down
10 changes: 9 additions & 1 deletion leveleditor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !deploy
// +build !deploy

package main

import (
Expand Down Expand Up @@ -35,7 +38,12 @@ func levelEditor() {
goToStartPosition()
}
}
xCellRune := ' '
if xCell := (player.x-frameWidth/2)/(frameWidth*26) + 64; xCell > 64 {
xCellRune = rune(xCell)
}
pos := fmt.Sprintf("%c%c:%d", xCellRune, rune(((player.x-frameWidth/2)/frameWidth)%26+65), player.y/frameWidth+1)

message = message + fmt.Sprintf("\nEDIT MODE: (r)eload (s)pawn\ntps %d fps %d", int(ebiten.CurrentTPS()), int(ebiten.CurrentFPS()))
message = message + fmt.Sprintf("\n[%s](r)eload (s)pawn\ntps %d fps %d", pos, int(ebiten.CurrentTPS()), int(ebiten.CurrentFPS()))

}

0 comments on commit 7613dae

Please sign in to comment.