Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.93 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. type KeySet struct {
  8.     Keys    map[int]bool
  9. }
  10.  
  11. func NewKeySet() *KeySet {
  12.     set := &KeySet{
  13.         Keys: make(map[int]bool),
  14.     }
  15.     return set
  16. }
  17.  
  18. func (k *KeySet) Add(toAdd int) {
  19.     k.Keys[toAdd] = true
  20. }
  21.  
  22. func (k *KeySet) Remove(toRemove int) {
  23.     k.Keys[toRemove] = false
  24. }
  25.  
  26. func (k *KeySet) Contains(toCheck int) bool {
  27.     return k.Keys[toCheck]
  28. }
  29.  
  30. type Block struct {
  31.     Color   string
  32. }
  33.  
  34. type GameBoard struct {
  35.     Blocks  [][]*Block
  36. }
  37.  
  38. func NewGameBoard() *GameBoard {
  39.     rows := make([][]*Block, 20)
  40.     for i := 0; i < 20; i++ {
  41.         row := make([]*Block, 10)
  42.         rows[i] = row
  43.     }
  44.     return &GameBoard{
  45.         Blocks: rows,
  46.     }
  47. }
  48.  
  49.  
  50.  
  51.  
  52. type Game struct {
  53.     GameBoard   *GameBoard
  54.     MoveCounter uint64
  55. }
  56.  
  57. func (g *Game) SetupNewGame() {
  58.     g.GameBoard = NewGameBoard()
  59.     g.MoveCounter = 0
  60. }
  61.  
  62.  
  63.  
  64. func main() {
  65.     gb := NewGameBoard()
  66.     fmt.Println(gb.Blocks[19]);
  67.    
  68.     fmt.Println("Hello, playground")
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement