Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- )
- type KeySet struct {
- Keys map[int]bool
- }
- func NewKeySet() *KeySet {
- set := &KeySet{
- Keys: make(map[int]bool),
- }
- return set
- }
- func (k *KeySet) Add(toAdd int) {
- k.Keys[toAdd] = true
- }
- func (k *KeySet) Remove(toRemove int) {
- k.Keys[toRemove] = false
- }
- func (k *KeySet) Contains(toCheck int) bool {
- return k.Keys[toCheck]
- }
- type Block struct {
- Color string
- }
- type GameBoard struct {
- Blocks [][]*Block
- }
- func NewGameBoard() *GameBoard {
- rows := make([][]*Block, 20)
- for i := 0; i < 20; i++ {
- row := make([]*Block, 10)
- rows[i] = row
- }
- return &GameBoard{
- Blocks: rows,
- }
- }
- type Game struct {
- GameBoard *GameBoard
- MoveCounter uint64
- }
- func (g *Game) SetupNewGame() {
- g.GameBoard = NewGameBoard()
- g.MoveCounter = 0
- }
- func main() {
- gb := NewGameBoard()
- fmt.Println(gb.Blocks[19]);
- fmt.Println("Hello, playground")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement