| 
									
										
										
										
											2019-03-08 10:05:39 +03:00
										 |  |  | // For more tutorials: https://blog.learngoprogramming.com | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Copyright © 2018 Inanc Gumus | 
					
						
							|  |  |  | // Learn Go Programming Course | 
					
						
							|  |  |  | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | 	const ( | 
					
						
							|  |  |  | 		width  = 50 | 
					
						
							|  |  |  | 		height = 10 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		cellEmpty = ' ' | 
					
						
							|  |  |  | 		cellBall  = '⚾' | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var cell rune // current cell (for caching) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// create the board | 
					
						
							|  |  |  | 	board := make([][]bool, width) | 
					
						
							| 
									
										
										
										
											2019-03-21 23:48:48 +03:00
										 |  |  | 	for column := range board { | 
					
						
							|  |  |  | 		board[column] = make([]bool, height) | 
					
						
							| 
									
										
										
										
											2019-03-08 10:05:39 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// draw a smiley | 
					
						
							|  |  |  | 	board[12][2] = true | 
					
						
							|  |  |  | 	board[16][2] = true | 
					
						
							|  |  |  | 	board[14][4] = true | 
					
						
							|  |  |  | 	board[10][6] = true | 
					
						
							|  |  |  | 	board[18][6] = true | 
					
						
							|  |  |  | 	board[12][7] = true | 
					
						
							|  |  |  | 	board[14][7] = true | 
					
						
							|  |  |  | 	board[16][7] = true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// print the board directly to the console | 
					
						
							|  |  |  | 	for y := range board[0] { | 
					
						
							|  |  |  | 		for x := range board { | 
					
						
							|  |  |  | 			cell = cellEmpty | 
					
						
							|  |  |  | 			if board[x][y] { | 
					
						
							|  |  |  | 				cell = cellBall | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			fmt.Print(string(cell), " ") | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		fmt.Println() | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |