Exemple #1
0
func drawGameNextPiece(screen *image.Image, world *World, engine *mygameengine.MyGameEngine) {
	piece := world.GetNextPiece()
	pieceBlocks := piece.GetBlocks()
	pieceSize := piece.GetSize()

	marginLeft := uint(15)
	marginTop := uint(8)
	width := uint(6)

	// border
	for y := uint(0); y < width; y++ {
		for x := uint(0); x < width; x++ {
			if x == 0 || y == 0 || x == 5 || y == 5 {
				screen.BlitAt(
					engine.Assets().Get(IMG_BLOCK_05),
					int(BLOCK_SIZE*marginLeft+uint(x)*BLOCK_SIZE),
					int(BLOCK_SIZE*marginTop+uint(y)*BLOCK_SIZE),
				)
			}
		}
	}
	// piece
	for y := uint(0); y < pieceSize; y++ {
		for x := uint(0); x < pieceSize; x++ {
			if pieceBlocks[y][x] != nil {
				image := blockToImage(pieceBlocks[y][x], engine)
				screen.BlitAt(
					image,
					int(BLOCK_SIZE*(marginLeft+1)+uint(x)*BLOCK_SIZE),
					int(BLOCK_SIZE*(marginTop+1)+uint(y)*BLOCK_SIZE),
				)
			}
		}
	}
}
Exemple #2
0
func drawIntroMask(screen *image.Image, frame uint64, fps uint) {
	var maxFrame uint64 = uint64(maskDuration * fps)

	if frame < maxFrame {
		black := mygameengine.COLOR_BLACK
		black.A = uint8(math.Max(0, 255-float64(frame)*(255/float64(maxFrame))))
		screen.DrawRectangle(0, 0, 640, 480, black)
	}
}
Exemple #3
0
func drawGameGrid(screen *image.Image, world *World, engine *mygameengine.MyGameEngine) {
	gridWidth := world.GetGridWidth()
	gridHeight := world.GetGridHeight()
	blocks := world.GetGrid()
	for y := uint(0); y < gridHeight; y++ {
		for x := uint(0); x < gridWidth; x++ {
			if blocks[y][x] != nil {
				image := blockToImage(blocks[y][x], engine)
				screen.BlitAt(image, int(BLOCK_SIZE+x*BLOCK_SIZE), int(y*BLOCK_SIZE))
			}
		}
	}
}
Exemple #4
0
func drawGameCurrentPiece(screen *image.Image, world *World, engine *mygameengine.MyGameEngine) {
	piece := world.GetPiece()
	pieceBlocks := piece.GetBlocks()
	pieceSize := int(piece.GetSize())
	pieceY := world.GetPieceY()
	pieceX := world.GetPieceX()

	for y := 0; y < pieceSize; y++ {
		for x := 0; x < pieceSize; x++ {
			if pieceBlocks[y][x] != nil {
				image := blockToImage(pieceBlocks[y][x], engine)
				screen.BlitAt(
					image,
					int(BLOCK_SIZE+uint(pieceX+x)*BLOCK_SIZE),
					int(uint(pieceY+y)*BLOCK_SIZE),
				)
			}
		}
	}
}
Exemple #5
0
func drawIntroBackground(screen *image.Image, frame uint64, imageIntroRotatingBg *image.Image) {
	var y int = int(math.Mod(float64(frame), 217))

	screen.BlitAt(imageIntroRotatingBg, 0, y-217)
	screen.BlitAt(imageIntroRotatingBg, 0, y)
	screen.BlitAt(imageIntroRotatingBg, 0, y+217)
	screen.BlitAt(imageIntroRotatingBg, 0, y+434)
}
Exemple #6
0
func drawGameGridBorders(screen *image.Image, world *World, engine *mygameengine.MyGameEngine) {
	gridWidth := world.GetGridWidth()
	gridHeight := world.GetGridHeight()
	for y := uint(0); y < gridHeight; y++ {
		screen.BlitAt(engine.Assets().Get(IMG_BLOCK_05), 0, int(y*BLOCK_SIZE))
		screen.BlitAt(engine.Assets().Get(IMG_BLOCK_06), int(gridWidth*BLOCK_SIZE+BLOCK_SIZE), int(y*BLOCK_SIZE))
	}
	for x := uint(0); x < gridWidth+2; x++ {
		screen.BlitAt(engine.Assets().Get(IMG_BLOCK_06), int(x*BLOCK_SIZE), int(gridHeight*BLOCK_SIZE))
	}
}
Exemple #7
0
func drawIntroText(screen *image.Image, frame uint64, imageIntroText *image.Image) {
	var v int = int(math.Mod(float64(frame), 50))
	if v > 25 {
		screen.BlitAt(imageIntroText, 210, 370)
	}
}
Exemple #8
0
func drawGameBackground(screen *image.Image) {
	screen.DrawRectangle(0, 0, 640, 480, mygameengine.COLOR_BLACK)
}
Exemple #9
0
func drawGameFlash(screen *image.Image, flash int) {
	white := mygameengine.COLOR_WHITE
	white.A = uint8(25 * flash)
	screen.DrawRectangle(0, 0, 640, 480, white)
}