As a student with limited resources and only a Chromebook, I want to create a game. However, many people suggest I need higher processing power and more advanced technology. One day, I watched a YouTube video about B.Tecky. I learned that Amazon's Q technology is incredibly powerful. With just one prompt, I was able to generate a game, and it was both efficient and impressive.
**
Intro:
**
Video games are getting AI at the heart of this evolution. I set out to create a game called "ALIEN RPG".I used Amazon Q, an advanced AI assistant by AWS, to speed up development and power the brains behind the game. In this game, we control this game by giving commands like type 1 enter, type 2 enter, and type 3 enter . We control this game with this command. It's like a Q and A gam e. Wee give you 3 options like Attack, Use Item and Run.
**
What is Amazon Q?**
Amazon Q is a powerful AI tool designed by AWS to help developers build applications faster. Whether you’re writing code, generating assets, or managing logic, Amazon Q can assist with smart suggestions, code generation, and even integrations with your tools. For game developers, this opens up new ways to build dynamic and intelligent game systems.
Alien RPG gameplay
This is the first screen of the game, When we start a game, it shows like that.
First, we give a command 1 for New Game and 2 for Quit.
When we type 1 and enter, they give the 2nd screen.
Here, enter your name.
After entering the name, they give us 3rd screen.
So, they give you three options when you go with 1st option and type 1 and enter they give fourth screen.
Welcome to the game! You will attack and defend by choosing 1, 2, or 3.
Key Prompting Strategy:
- build a game like a stone story they rpg fight eith aliens
Conversation,code and chat of Amazon Q
build a game like a stone story they rpg fight eith aliens
I'll help you build a text-based RPG game with alien combat, inspired by Stone Story RPG's ASCII art style. Let's
create a simple game in Python that features:
- ASCII art for visuals
- Turn-based combat with aliens
- Basic RPG elements like health, attack, and items Let's start by creating the main game file: 🛠️ Using tool: fs_write ⋮ ● Path: /home/arayachaudhar1309202/alien_rpg.py
- 1: #!/usr/bin/env python3
- 2: import random
- 3: import time
- 4: import os
- 5:
- 6: class Player:
- 7: def init(self, name):
- 8: self.name = name
- 9: self.health = 100
- 10: self.max_health = 100
- 11: self.attack = 15
- 12: self.defense = 5
- 13: self.inventory = ["Health Potion", "Energy Crystal"]
- 14: self.level = 1
- 15: self.exp = 0
- 16: self.exp_to_level = 100
- 17:
- 18: def take_damage(self, damage):
- 19: actual_damage = max(1, damage - self.defense)
- 20: self.health = max(0, self.health - actual_damage)
- 21: return actual_damage
- 22:
- 23: def heal(self, amount):
- 24: self.health = min(self.max_health, self.health + amount)
- 25:
- 26: def level_up(self):
- 27: self.level += 1
- 28: self.max_health += 20
- 29: self.health = self.max_health
- 30: self.attack += 5
- 31: self.defense += 2
- 32: self.exp_to_level = int(self.exp_to_level * 1.5)
- 33: print(f"\n╔═════════════════════════════════╗")
- 34: print(f"║ LEVEL UP! You are now level {self.level}! ║")
- 35: print(f"╚═════════════════════════════════╝")
- 36: print(f"Health: {self.max_health} | Attack: {self.attack} | Defense: {self.defense}")
- 37: time.sleep(2)
- 38:
- 39: def gain_exp(self, amount):
- 40: self.exp += amount
- 41: print(f"Gained {amount} experience points!")
- 42: if self.exp >= self.exp_to_level:
- 43: self.level_up()
- 44:
- 45: class Alien:
- 46: def init(self, level):
- 47: alien_types = [
- 48: {"name": "Crawler", "health": 30, "attack": 10, "defense": 2, "exp": 20,
- 49: "ascii": [" ... ", " / \ ", " | O O | ", " | V | ", " \---/ ", " ||||| "]},
- 50: {"name": "Blaster", "health": 40, "attack": 15, "defense": 3, "exp": 35,
- 51: "ascii": [" .---. ", " / \ ", "| - - |", "| ^ |", " \--_/ ", " ||||| "]},
- 52: {"name": "Sentinel", "health": 60, "attack": 12, "defense": 8, "exp": 50,
- 53: "ascii": [" /|\ ", " / | \ ", " /--|--\ ", "/ | \", " | ", " / \ "]}
- 54: ]
- 55:
- 56: alien_type = random.choice(alien_types)
- 57: self.name = alien_type["name"]
- 58: self.health = alien_type["health"] + (level * 5)
- 59: self.max_health = self.health
- 60: self.attack = alien_type["attack"] + (level * 2)
- 61: self.defense = alien_type["defense"] + level
- 62: self.exp_reward = alien_type["exp"] + (level * 10)
- 63: self.ascii = alien_type["ascii"]
- 64:
- 65: def take_damage(self, damage):
- 66: actual_damage = max(1, damage - self.defense)
- 67: self.health = max(0, self.health - actual_damage)
- 68: return actual_damage
- 69:
- 70: def clear_screen():
- 71: os.system('cls' if os.name == 'nt' else 'clear')
- 72:
- 73: def display_health_bar(current, maximum, length=20):
- 74: filled_length = int(length * current / maximum)
- 75: bar = '█' * filled_length + '░' * (length - filled_length)
- 76: percentage = int(100 * current / maximum)
- 77: return f"{bar} {current}/{maximum} ({percentage}%)"
- 78:
- 79: def display_battle(player, alien):
- 80: clear_screen()
- 81: print("\n" + "═" * 60)
- 82: print(f" {player.name} vs {alien.name}")
- 83: print("═" * 60)
- 84:
- 85: # Display alien ASCII art
- 86: for line in alien.ascii:
- 87: print(f"{' ' * 25}{line}")
- 88:
- 89: print("\n" + "─" * 60)
- 90: print(f"Player: {player.name} (Level {player.level})")
- 91: print(f"HP: {display_health_bar(player.health, player.max_health)}")
- 92: print(f"Attack: {player.attack} | Defense: {player.defense}")
- 93: print("─" * 60)
- 94: print(f"Alien: {alien.name}")
- 95: print(f"HP: {display_health_bar(alien.health, alien.max_health)}")
- 96: print(f"Attack: {alien.attack} | Defense: {alien.defense}")
- 97: print("═" * 60)
- 98:
- 99: def player_turn(player, alien):
- 100: print("\nYour turn! What would you like to do?")
- 101: print("1. Attack")
- 102: print("2. Use Item")
- 103: print("3. Run Away")
- 104:
- 105: while True:
- 106: choice = input("> ")
- 107: if choice == "1":
- 108: damage_dealt = alien.take_damage(player.attack)
- 109: print(f"You attack the {alien.name} for {damage_dealt} damage!")
- 110: time.sleep(1)
- 111: return True
- 112: elif choice == "2":
- 113: if not player.inventory:
- 114: print("Your inventory is empty!")
- 115: time.sleep(1)
- 116: continue
- 117:
- 118: print("\nInventory:")
- 119: for i, item in enumerate(player.inventory, 1):
- 120: print(f"{i}. {item}")
- 121: print("0. Back")
- 122:
- 123: item_choice = input("Select an item to use (or 0 to go back): ")
- 124: if item_choice == "0":
- 125: continue
- 126:
- 127: try:
- 128: item_index = int(item_choice) - 1
- 129: if 0 <= item_index < len(player.inventory):
- 130: item = player.inventory.pop(item_index)
- 131: if item == "Health Potion":
- 132: heal_amount = 30
- 133: player.heal(heal_amount)
- 134: print(f"You used a Health Potion and recovered {heal_amount} health!")
- 135: elif item == "Energy Crystal":
- 136: damage_dealt = alien.take_damage(25)
- 137: print(f"You used an Energy Crystal! It blasts the {alien.name} for {damage_dealt} damage!")
- 138: time.sleep(1)
- 139: return True
- 140: else:
- 141: print("Invalid item number!")
- 142: except ValueError:
- 143: print("Please enter a number!")
- 144: elif choice == "3":
- 145: if random.random() < 0.5:
- 146: print("You managed to escape!")
- 147: time.sleep(1)
- 148: return False
- 149: else:
- 150: print("You couldn't escape!")
- 151: time.sleep(1)
- 152: return True
- 153: else:
- 154: print("Invalid choice! Try again.")
- 155:
- 156: def alien_turn(player, alien):
- 157: print(f"\nThe {alien.name}'s turn!")
- 158: time.sleep(0.5)
- 159:
- 160: # Aliens have a chance to perform special moves
- 161: move_type = random.choices(
- 162: ["attack", "special"],
- 163: weights=[0.7, 0.3],
- 164: k=1
- 165: )[0]
- 166:
- 167: if move_type == "attack":
- 168: damage_dealt = player.take_damage(alien.attack)
- 169: print(f"The {alien.name} attacks you for {damage_dealt} damage!")
- 170: else:
- 171: if alien.name == "Crawler":
- 172: damage_dealt = player.take_damage(int(alien.attack * 1.5))
- 173: print(f"The {alien.name} uses Acid Spray for {damage_dealt} damage!")
- 174: elif alien.name == "Blaster":
- 175: damage_dealt = player.take_damage(alien.attack * 2)
- 176: print(f"The {alien.name} uses Energy Blast for {damage_dealt} damage!")
- 177: elif alien.name == "Sentinel":
- 178: alien.health = min(alien.max_health, alien.health + 10)
- 179: print(f"The {alien.name} uses Regeneration and recovers 10 health!")
- 180:
- 181: time.sleep(1)
- 182: return True
- 183:
- 184: def battle(player, alien):
- 185: battle_active = True
- 186:
- 187: while battle_active:
- 188: display_battle(player, alien)
- 189:
- 190: # Player's turn
- 191: battle_active = player_turn(player, alien)
- 192: if not battle_active:
- 193: return "escaped"
- 194:
- 195: # Check if alien is defeated
- 196: if alien.health <= 0:
- 197: display_battle(player, alien)
- 198: print(f"\nYou defeated the {alien.name}!")
- 199: player.gain_exp(alien.exp_reward)
- 200:
- 201: # Random loot
- 202: if random.random() < 0.3:
- 203: loot = random.choice(["Health Potion", "Energy Crystal"])
- 204: player.inventory.append(loot)
- 205: print(f"You found a {loot}!")
- 206:
- 207: time.sleep(2)
- 208: return "victory"
- 209:
- 210: # Alien's turn
- 211: display_battle(player, alien)
- 212: battle_active = alien_turn(player, alien)
- 213:
- 214: # Check if player is defeated
- 215: if player.health <= 0:
- 216: display_battle(player, alien)
- 217: print("\nYou have been defeated!")
- 218: time.sleep(2)
- 219: return "defeat"
- 220:
- 221: time.sleep(1)
- 222:
- 223: def explore(player):
- 224: clear_screen()
- 225: print("\n" + "═" * 60)
- 226: print("You venture deeper into the alien territory...")
- 227: print("═" * 60)
- 228:
- 229: events = [
- 230: {"type": "battle", "weight": 0.7},
- 231: {"type": "item", "weight": 0.2},
- 232: {"type": "rest", "weight": 0.1}
- 233: ]
- 234:
- 235: event_types = [e["type"] for e in events]
- 236: weights = [e["weight"] for e in events]
- 237:
- 238: event = random.choices(event_types, weights=weights, k=1)[0]
- 239:
- 240: if event == "battle":
- 241: print("You encounter an alien!")
- 242: time.sleep(1)
- 243: alien = Alien(max(1, player.level - 1 + random.randint(0, 2)))
- 244: result = battle(player, alien)
- 245:
- 246: if result == "defeat":
- 247: return False
- 248:
- 249: elif event == "item":
- 250: items = ["Health Potion", "Energy Crystal"]
- 251: item = random.choice(items)
- 252: player.inventory.append(item)
- 253: print(f"You found a {item}!")
- 254: time.sleep(2)
- 255:
- 256: elif event == "rest":
- 257: heal_amount = player.max_health // 4
- 258: player.heal(heal_amount)
- 259: print(f"You found a safe spot to rest and recovered {heal_amount} health.")
- 260: time.sleep(2)
- 261:
- 262: return True
- 263:
- 264: def main_menu():
- 265: clear_screen()
- 266: print("\n" + "═" * 60)
- 267: print("""
- 268: █████╗ ██╗ ██╗███████╗███╗ ██╗ ██████╗ ██████╗ ██████╗
- 269: ██╔══██╗██║ ██║██╔════╝████╗ ██║ ██╔══██╗██╔══██╗██╔════╝
- 270: ███████║██║ ██║█████╗ ██╔██╗ ██║ ██████╔╝██████╔╝██║ ███╗
- 271: ██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██╔══██╗██╔═══╝ ██║ ██║
- 272: ██║ ██║███████╗██║███████╗██║ ╚████║ ██║ ██║██║ ╚██████╔╝
- 273: ╚═╝ ╚═╝╚══════╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═════╝
- 274: """)
- 275: print("═" * 60)
- 276: print("\n1. New Game")
- 277: print("2. Quit")
- 278:
- 279: choice = input("\n> ")
- 280: if choice == "1":
- 281: return True
- 282: else:
- 283: return False
- 284:
- 285: def game_over(player):
- 286: clear_screen()
- 287: print("\n" + "═" * 60)
- 288: print("""
- 289: ██████╗ █████╗ ███╗ ███╗███████╗ ██████╗ ██╗ ██╗███████╗██████╗
- 290: ██╔════╝ ██╔══██╗████╗ ████║██╔════╝ ██╔═══██╗██║ ██║██╔════╝██╔══██╗
- 291: ██║ ███╗███████║██╔████╔██║█████╗ ██║ ██║██║ ██║█████╗ ██████╔╝
- 292: ██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██╗
- 293: ╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ╚██████╔╝ ╚████╔╝ ███████╗██║ ██║
- 294: ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
- 295: """)
- 296: print("═" * 60)
- 297: print(f"\nYou were defeated at level {player.level}!")
- 298: print(f"Experience points: {player.exp}")
- 299: print(f"Items collected: {len(player.inventory)}")
- 300:
- 301: input("\nPress Enter to return to the main menu...")
- 302:
- 303: def game_loop():
- 304: if not main_menu():
- 305: return
- 306:
- 307: clear_screen()
- 308: print("\nWelcome, brave warrior! Earth is under attack by alien forces.")
- 309: print("You are humanity's last hope. Fight the aliens and save our planet!")
- 310:
- 311: player_name = input("\nEnter your name: ")
- 312: player = Player(player_name)
- 313:
- 314: game_active = True
- 315: while game_active:
- 316: clear_screen()
- 317: print("\n" + "═" * 60)
- 318: print(f"Name: {player.name} | Level: {player.level} | EXP: {player.exp}/{player.exp_to_level}")
- 319: print(f"Health: {display_health_bar(player.health, player.max_health)}")
- 320: print(f"Attack: {player.attack} | Defense: {player.defense}")
- 321: print(f"Inventory: {', '.join(player.inventory) if player.inventory else 'Empty'}")
- 322: print("═" * 60)
- 323: print("\n1. Explore")
- 324: print("2. Rest (Recover 30% HP)")
- 325: print("3. Quit")
- 326:
- 327: choice = input("\n> ")
- 328: if choice == "1":
- 329: game_active = explore(player)
- 330: elif choice == "2":
- 331: heal_amount = int(player.max_health * 0.3)
- 332: player.heal(heal_amount)
- 333: print(f"You rest and recover {heal_amount} health.")
- 334: time.sleep(2)
- 335: elif choice == "3":
- 336: break
- 337: else:
- 338: print("Invalid choice!")
- 339: time.sleep(1)
- 340:
- 341: if not game_active:
- 342: game_over(player)
- 343:
- 344: if name == "main":
- 345: while True:
- 346: game_loop()
- 347: if input("\nPlay again? (y/n): ").lower() != 'y':
- 348: break Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]: > y Creating: /home/arayachaudhar1309202/alien_rpg.py ⋮ ● Completed in 0.9s I've created a text-based RPG game called "Alien RPG" in Python. The game is now saved to /home/arayachaudhar1309202/alien_rpg.py. Here's what it includes: ## Game Features • ASCII art representation of aliens • Turn-based combat system • Character progression with levels and experience • Different types of aliens (Crawler, Blaster, Sentinel) • Inventory system with usable items • Health bars and stat displays • Special alien abilities • Random events while exploring ## How to Play
- Run the game with: python3 alien_rpg.py
- Enter your character name when prompted
- Choose actions from the menu: • Explore: Find aliens to fight or items to collect • Rest: Recover some health • Quit: Exit the game During combat, you can: • Attack aliens • Use items from your inventory • Try to run away ## Game Elements • Player stats: Health, attack, defense, level, and experience • Alien types: Each with unique stats and special abilities • Items: Health potions and energy crystals • Random events: Battles, item discoveries, and rest spots The game features ASCII art visuals and health bars to give it a Stone Story RPG feel while maintaining the alien combat theme you requested. Would you like me to explain any specific part of the code or make any adjustments to the game?