-
Notifications
You must be signed in to change notification settings - Fork 1
/
constants.go
79 lines (63 loc) · 1.62 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
const (
defaultCodeDir = "gosrc"
defaultSourceFile = "main.go"
defaultCompileDir = "js"
defaultOutputFile = "cart.js"
ebitenRepo = "github.com/hajimehoshi/ebiten"
)
const aboutBody = "Welcome on to `pico-go`\n\nThe golang fantasy console.\n\nby @telecoda\n"
const demoSrc = `package main
/*
This is a simple demo project to show you how to use pico-go
Copyright 2018 @telecoda
*/
import "github.com/telecoda/pico-go-electron/console"
const (
// set console type to one of the predefined consoles
consoleType = console.PICO8
// define these vars to be used in javascript canvas scaling code
screenWidth = 128
screenHeight = 128
)
type cartridge struct {
*console.BaseCartridge
}
// Init - called once
func (c *cartridge) Init() error {
console.ShowFPS()
return nil
}
// Update - called once every frame
func (c *cartridge) Update() {
}
// Render - called once every frame
func (c *cartridge) Render() {
c.ClsWithColor(console.PICO8_BLUE)
c.PrintAt("Hello", 10, 20)
}`
const genMainSrc = `/*
This is the generated bootstrap code for running a pico-go cartridge.
Don't change any of this code, you shouldn't even really be seeing it, I guess you're the curious type.
*/
package main
import (
"fmt"
"github.com/telecoda/pico-go-electron/console"
)
func NewCart() console.Cartridge {
return &cartridge{
BaseCartridge: console.NewBaseCart(),
}
}
func main() {
cart := NewCart()
if err := console.Init(consoleType); err != nil {
fmt.Printf("Failed to init console: %s\n", err)
return
}
if err := console.Run(cart); err != nil {
fmt.Printf("Failed to run cartridge: %s\n", err)
return
}
}`