Skip to content

Commit

Permalink
coins indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgraybill committed Apr 25, 2022
1 parent e4c1cd6 commit b043986
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 28 deletions.
10 changes: 10 additions & 0 deletions drawscreen.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package main

import (
"fmt"
"image"
"image/color"

"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
"github.com/hajimehoshi/ebiten/v2/text"
"github.com/jcgraybill/it-costs-money/sys"
)

Expand Down Expand Up @@ -45,8 +48,15 @@ func (g *Game) Draw(screen *ebiten.Image) {

frameBuffer.DrawImage((*g.player.Slides)[i], runnerOP)
frameBuffer.DrawImage(g.level.LevelForegroundImage.SubImage(levelViewFinder).(*ebiten.Image), nil)

ebitenutil.DebugPrint(frameBuffer, message)
screen.DrawImage(frameBuffer, nil)

coins := fmt.Sprintf("Coins: %d", g.player.Coins)
textBounds := text.BoundString(*g.ttf, coins)
text.Draw(screen, coins, *g.ttf, sys.ScreenWidth-textBounds.Dx()-18, textBounds.Dy()+2, color.RGBA{0x00, 0x00, 0x00, 0xff})
text.Draw(screen, coins, *g.ttf, sys.ScreenWidth-textBounds.Dx()-20, textBounds.Dy(), color.RGBA{0xd4, 0xaf, 0x47, 0xff})

}

func parallax(image *ebiten.Image, offset int, speed int) {
Expand Down
2 changes: 1 addition & 1 deletion gameloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func (g *Game) Update() error {
g.count++
g.player.Slides = &g.player.IdleFrames
message = fmt.Sprintf("Gather coins and bring them to the green chest.\nIt costs money to be alive!\nYour coins: %d", g.player.Coins)
message = "Gather coins and bring them to the green chest.\nIt costs money to be alive!\n"

touchingGround, touchingLeft, leftAdjacent, touchingRight, rightAdjacent, touchingTop := detectCollisions(g)

Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ module github.com/jcgraybill/it-costs-money

go 1.18

require github.com/hajimehoshi/ebiten/v2 v2.3.0
require (
github.com/hajimehoshi/ebiten/v2 v2.3.0
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
)

require (
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220320163800-277f93cfa958 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/hajimehoshi/oto/v2 v2.1.0 // indirect
github.com/jezek/xgb v1.0.0 // indirect
github.com/jfreymuth/oggvorbis v1.0.3 // indirect
github.com/jfreymuth/vorbis v1.0.2 // indirect
golang.org/x/exp/shiny v0.0.0-20220414153411-bcd21879b8fd // indirect
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 // indirect
golang.org/x/mobile v0.0.0-20220414153400-ce6a79cf6a13 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/text v0.3.7 // indirect
)
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ github.com/hajimehoshi/oto/v2 v2.1.0/go.mod h1:9i0oYbpJ8BhVGkXDKdXKfFthX1JUNfXje
github.com/jakecoffman/cp v1.1.0/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
github.com/jezek/xgb v1.0.0 h1:s2rRzAV8KQRlpsYA7Uyxoidv1nodMF0m6dIG6FhhVLQ=
github.com/jezek/xgb v1.0.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/jfreymuth/oggvorbis v1.0.3 h1:MLNGGyhOMiVcvea9Dp5+gbs2SAwqwQbtrWnonYa0M0Y=
github.com/jfreymuth/oggvorbis v1.0.3/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII=
github.com/jfreymuth/vorbis v1.0.2 h1:m1xH6+ZI4thH927pgKD8JOH4eaGRm18rEE9/0WKjvNE=
github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand Down Expand Up @@ -74,6 +72,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
Expand Down
33 changes: 15 additions & 18 deletions level/coin/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package coin

import (
"bytes"
"fmt"

"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/audio"
"github.com/hajimehoshi/ebiten/v2/audio/vorbis"
"github.com/hajimehoshi/ebiten/v2/audio/wav"
"github.com/jcgraybill/it-costs-money/sys"
)

Expand All @@ -15,6 +14,7 @@ type Coin struct {
NumSlides int
AnimationSpeed int
AudioPlayers [5]*audio.Player
audioPlayer *audio.Player
Coins []*Coins
}

Expand All @@ -32,25 +32,22 @@ func New(audioContext *audio.Context) Coin {

c.Coins = make([]*Coins, 0)

for i := 0; i < 5; i++ {
audioBytes, err := sys.GameData(fmt.Sprintf("assets/Coins_Grab_0%d.ogg", i))
if err != nil {
panic(err)
}
d, err := vorbis.Decode(audioContext, bytes.NewReader(audioBytes))
if err != nil {
panic(err)
}
c.AudioPlayers[i], err = audioContext.NewPlayer(d)
if err != nil {
panic(err)
}

audioBytes, err := sys.GameData("assets/smb_coin.wav")
if err != nil {
panic(err)
}
d, err := wav.Decode(audioContext, bytes.NewReader(audioBytes))
if err != nil {
panic(err)
}
c.audioPlayer, err = audioContext.NewPlayer(d)
if err != nil {
panic(err)
}
return c
}

func (c Coin) PlaySound(count int) {
c.AudioPlayers[count%5].Rewind()
c.AudioPlayers[count%5].Play()
c.audioPlayer.Rewind()
c.audioPlayer.Play()
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
"github.com/jcgraybill/it-costs-money/level"
"github.com/jcgraybill/it-costs-money/player"
"github.com/jcgraybill/it-costs-money/sys"
"golang.org/x/image/font"
)

type Game struct {
count int
level level.Level
player player.Player
tiles []*ebiten.Image
ttf *font.Face
}

var frameBuffer *ebiten.Image
Expand All @@ -30,6 +32,7 @@ func main() {

var g Game
g.count = 0
g.ttf = sys.Font()
g.tiles = sys.LoadSpriteSheet("assets/1-tiles-city.png")
g.tiles = append(g.tiles, sys.LoadSpriteSheet("assets/2-tiles-country.png")...)
g.tiles = append(g.tiles, sys.LoadSpriteSheet("assets/3-objects-city.png")...)
Expand Down
Binary file added sys/assets/smb_coin.wav
Binary file not shown.
2 changes: 1 addition & 1 deletion sys/leveldata/level_1_actors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c,c,c,c,c,0,0,c,c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c,c,c,0,0,0,0,0,0,0,c,0,0,c,c,0,0,0,0,0,c,c,c,c,c,0,0,c,c,0,0,c,0,c,0,c,0,c,0,c,0,c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 changes: 1 addition & 1 deletion sys/leveldata/level_1_background.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
0,10,11,11,11,11,11,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,325,326,327,328,329,330,331,332,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,738,739,740,741,742,743,744,745,746,747,748,749,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,738,739,740,741,742,743,744,745,746,747,748,749,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,347,348,349,350,351,352,353,354,265,266,267,268,269,270,271,272,0,0,0,0,0,0,0,0,0,,0,813,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,881,882,883,884,885,886,0
0,10,11,11,11,11,11,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,355,356,357,358,359,360,361,362,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,768,769,770,771,772,773,774,775,776,777,778,779,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,11,11,11,11,11,11,11,12,10,11,11,11,11,11,12,10,11,11,11,11,11,12,0,768,769,770,771,772,773,774,775,776,777,778,779,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,528,529,530,531,532,533,534,295,296,297,298,299,300,301,302,0,0,0,0,0,0,0,0,0,841,842,843,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,911,912,913,914,915,916,0
2,22,11,11,11,11,11,12,0,0,0,0,0,0,0,0,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,635,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,798,799,800,801,802,803,804,805,806,807,808,809,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,637,638,639,640,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,861,862,857,858,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,11,11,11,11,11,11,11,12,10,11,11,11,11,11,12,10,11,11,11,11,11,12,0,798,799,800,801,802,803,804,805,806,807,808,809,695,696,695,696,695,696,695,696,696,695,696,695,696,695,696,557,558,559,560,561,562,563,564,325,326,327,328,329,330,331,332,0,0,0,0,0,0,0,0,0,871,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,859,860,943,944,945,946,0
11,11,11,11,11,11,11,12,0,0,0,0,0,0,0,0,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,828,829,830,831,832,833,834,835,836,837,838,839,0,0,37,38,38,38,38,38,38,39,0,0,0,0,0,0,667,668,669,670,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,891,892,887,888,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,11,11,11,11,11,11,11,12,10,11,11,11,11,11,12,10,11,11,11,11,11,12,1117,828,829,830,831,832,833,834,835,836,837,838,839,725,726,725,726,725,726,725,726,726,725,726,725,726,725,726,587,588,589,590,591,592,593,594,355,356,357,358,359,360,361,362,0,0,0,0,0,0,0,0,0,901,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,889,890,973,974,305,306,0
11,11,11,11,11,11,11,12,0,0,0,0,1117,0,0,0,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,828,829,830,831,832,833,834,835,836,837,838,839,0,0,37,38,38,38,38,38,38,39,0,0,0,0,0,0,667,668,669,670,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,891,892,887,888,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,11,11,11,11,11,11,11,12,10,11,11,11,11,11,12,10,11,11,11,11,11,12,1117,828,829,830,831,832,833,834,835,836,837,838,839,725,726,725,726,725,726,725,726,726,725,726,725,726,725,726,587,588,589,590,591,592,593,594,355,356,357,358,359,360,361,362,0,0,0,0,0,0,0,0,0,901,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,889,890,973,974,305,306,0
20,20,20,20,20,20,20,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,148,148,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,148,148,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 changes: 1 addition & 1 deletion sys/leveldata/level_2_actors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,s,0,c,c,0,c,0,c,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,s,0,0,c,c,0,0,c,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
22 changes: 22 additions & 0 deletions sys/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
_ "image/png"

"github.com/hajimehoshi/ebiten/v2"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)

func LoadImage(path string) *ebiten.Image {
Expand Down Expand Up @@ -38,3 +40,23 @@ func LoadSpriteSheet(path string) []*ebiten.Image {
sprites[i] = sprites[0]
return sprites
}

func Font() *font.Face {
ttbytes, err := GameData("assets/Modak-Regular.ttf")
if err == nil {
tt, err := opentype.Parse(ttbytes)
if err == nil {
fontface, err := opentype.NewFace(tt, &opentype.FaceOptions{
Size: 36,
DPI: 72,
Hinting: font.HintingFull,
})
if err == nil {
return &fontface
}
panic(err)
}
panic(err)
}
panic(err)
}

0 comments on commit b043986

Please sign in to comment.