Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
FROM golang:alpine3.8 as builder
WORKDIR /project
COPY surprise.go .
FROM --platform=$BUILDPLATFORM golang:1.11-alpine AS builder
RUN apk add --no-cache git
RUN go get github.com/pdevine/go-asciisprite
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o surprise surprise.go
WORKDIR /project
COPY surprise.go .

FROM scratch
ARG TARGETOS
ARG TARGETARCH
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH
RUN CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o surprise surprise.go

FROM scratch AS release-linux
COPY --from=builder /project/surprise /surprise
CMD ["/surprise"]
ENTRYPOINT ["/surprise"]

FROM microsoft/nanoserver AS release-windows
COPY --from=builder /project/surprise /surprise.exe
ENTRYPOINT ["\\surprise.exe"]

FROM release-$TARGETOS
9 changes: 7 additions & 2 deletions surprise.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ type Flicker struct {
func NewCake() *Cake {
s := &Cake{BaseSprite: sprite.BaseSprite{
Visible: true,
X: Width/2 - 20,
Y: Height/2},
}
s.AddCostume(sprite.NewCostume(birthday_c0, '@'))
s.X = Width/2 - s.Width/2

points := []sprite.Point{
sprite.Point{12, 0},
Expand Down Expand Up @@ -170,14 +170,19 @@ func main() {
cake := NewCake()
allSprites.Sprites = append(allSprites.Sprites, cake)

txt := "Press 'ESC' to quit."
c := sprite.NewCostume(txt, '~')
text := sprite.NewBaseSprite(Width/2-len(txt)/2, Height-2, c)
allSprites.Sprites = append(allSprites.Sprites, text)

mainloop:
for {
tm.Clear(tm.ColorDefault, tm.ColorDefault)

select {
case ev := <-event_queue:
if ev.Type == tm.EventKey {
if ev.Key == tm.KeyEsc || ev.Ch == 'q' {
if ev.Key == tm.KeyCtrlC || ev.Key == tm.KeyEsc || ev.Ch == 'q' {
break mainloop
}
} else if ev.Type == tm.EventResize {
Expand Down