This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
money <- 1000 | |
population <- 10 | |
city_name <- "" | |
buildings <- list() | |
display_menu <- function() { | |
cat("------------------\n") | |
cat("What do you want to do?\n") | |
cat("1. Build a building\n") | |
cat("2. Destroy a building\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CityBuilderGame | |
def initialize | |
@money = 1000 | |
@population = 10 | |
@city_name = "" | |
@buildings = [] | |
end | |
def start | |
puts "Welcome to the City Builder game!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdventureGame | |
def initialize | |
@player = { name: "", health: 100, inventory: [] } | |
@current_room = 0 | |
@rooms = [ | |
{ | |
name: "Forest", | |
description: "You are standing in a dark forest. There is a path to your left and right.", | |
paths: [1, 2], | |
items: [:stick] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WesternGame | |
def initialize | |
@player_health = 100 | |
@enemy_health = 100 | |
end | |
def start | |
puts "Welcome to the Western Game!\n" | |
while @player_health > 0 && @enemy_health > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'net/http' | |
class TriviaGame | |
def initialize | |
@score = 0 | |
end | |
def start | |
puts "Welcome to the Trivia Game!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
// Initialize the board | |
board := [9]string{" ", " ", " ", " ", " ", " ", " ", " ", " "} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicTacToe | |
def initialize | |
@board = Array.new(3) { Array.new(3, " ") } | |
@current_player = "X" | |
end | |
def play | |
loop do | |
display_board | |
print_turn_prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hangman | |
MAX_GUESSES = 6 | |
def initialize(word) | |
@word = word.upcase | |
@guesses = [] | |
@incorrect_guesses = 0 | |
end | |
def play |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"strings" | |
"time" | |
) | |
var words = []string{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
import random | |
class CricketGame: | |
def __init__(self, master): | |
self.master = master | |
self.master.title("Cricket Game") | |
# Labels | |
self.runs_label = tk.Label(master, text="Runs: 0") |