player input in survival game /u/Acceptable_Novel1564 Python Education

i need help with creating player input in my survival game heres the code if anyone wants it

import random

# creates player class

class Player:

def __init__(self, health, defence, speed, thirst, energy, inventory):

self.health = health

self.defence = defence

self.speed = speed

self.thirst = thirst

self.energy = energy

self.inventory = inventory

# defines the player’s stats

player_1 = {

“player”: Player(100, 2, 3, 100, 100, [])

}

player = player_1[“player”]

def play_turn(self):

while True:

# creates player input

player_1 = input(“what do you want to do? m for move, i for inventory, e for eat, d for drink, s for sleep, and c for craft”)

print(Player)

# defines player action

if player_1 == “m”:

print(“you moved”)

player.energy -= random.randint(3, 5)

player.thirst -= random.randint(5, 9)

# defines animal stats

class WildAnimal:

def __init__(self, health, damage, speed, defense):

self.health = health

self.damage = damage

self.speed = speed

self.defense = defense

# Create instances of different animals

wild_animals = {

“bear”: WildAnimal(200, 15, 10, 10),

“wolf”: WildAnimal(150, 20, 15, 5),

“snake”: WildAnimal(20, 30, 20, 5),

“deer”: WildAnimal(100, 10, 15, 5),

“elk”: WildAnimal(150, 15, 10, 10)

}

# defines items in game

class items:

def __init__(self, name, description, effect, duribility):

self.name = name

self.duribility = duribility

self.effect = effect

self.description = description

# defines item stats

items_stats = {

“stick”: items(“Stick”, “used for crafting”, “none”, 13),

“stone”: items(“Stone”, “used for crafting”, “none”, 23),

“grass”: items(“Grass”, “used for rope making”, “none”, 0),

“rope”: items(“Rope”, “can be used for making tools”, “scratches holder”, 123),

“knife”: items(“Knife”, “used for cutting grass”, “can accidentally cut user”, 150),

}

submitted by /u/Acceptable_Novel1564
[link] [comments]

​r/learnpython i need help with creating player input in my survival game heres the code if anyone wants it import random # creates player class class Player: def __init__(self, health, defence, speed, thirst, energy, inventory): self.health = health self.defence = defence self.speed = speed self.thirst = thirst self.energy = energy self.inventory = inventory # defines the player’s stats player_1 = { “player”: Player(100, 2, 3, 100, 100, []) } player = player_1[“player”] def play_turn(self): while True: # creates player input player_1 = input(“what do you want to do? m for move, i for inventory, e for eat, d for drink, s for sleep, and c for craft”) print(Player) # defines player action if player_1 == “m”: print(“you moved”) player.energy -= random.randint(3, 5) player.thirst -= random.randint(5, 9) # defines animal stats class WildAnimal: def __init__(self, health, damage, speed, defense): self.health = health self.damage = damage self.speed = speed self.defense = defense # Create instances of different animals wild_animals = { “bear”: WildAnimal(200, 15, 10, 10), “wolf”: WildAnimal(150, 20, 15, 5), “snake”: WildAnimal(20, 30, 20, 5), “deer”: WildAnimal(100, 10, 15, 5), “elk”: WildAnimal(150, 15, 10, 10) } # defines items in game class items: def __init__(self, name, description, effect, duribility): self.name = name self.duribility = duribility self.effect = effect self.description = description # defines item stats items_stats = { “stick”: items(“Stick”, “used for crafting”, “none”, 13), “stone”: items(“Stone”, “used for crafting”, “none”, 23), “grass”: items(“Grass”, “used for rope making”, “none”, 0), “rope”: items(“Rope”, “can be used for making tools”, “scratches holder”, 123), “knife”: items(“Knife”, “used for cutting grass”, “can accidentally cut user”, 150), } submitted by /u/Acceptable_Novel1564 [link] [comments] 

i need help with creating player input in my survival game heres the code if anyone wants it

import random

# creates player class

class Player:

def __init__(self, health, defence, speed, thirst, energy, inventory):

self.health = health

self.defence = defence

self.speed = speed

self.thirst = thirst

self.energy = energy

self.inventory = inventory

# defines the player’s stats

player_1 = {

“player”: Player(100, 2, 3, 100, 100, [])

}

player = player_1[“player”]

def play_turn(self):

while True:

# creates player input

player_1 = input(“what do you want to do? m for move, i for inventory, e for eat, d for drink, s for sleep, and c for craft”)

print(Player)

# defines player action

if player_1 == “m”:

print(“you moved”)

player.energy -= random.randint(3, 5)

player.thirst -= random.randint(5, 9)

# defines animal stats

class WildAnimal:

def __init__(self, health, damage, speed, defense):

self.health = health

self.damage = damage

self.speed = speed

self.defense = defense

# Create instances of different animals

wild_animals = {

“bear”: WildAnimal(200, 15, 10, 10),

“wolf”: WildAnimal(150, 20, 15, 5),

“snake”: WildAnimal(20, 30, 20, 5),

“deer”: WildAnimal(100, 10, 15, 5),

“elk”: WildAnimal(150, 15, 10, 10)

}

# defines items in game

class items:

def __init__(self, name, description, effect, duribility):

self.name = name

self.duribility = duribility

self.effect = effect

self.description = description

# defines item stats

items_stats = {

“stick”: items(“Stick”, “used for crafting”, “none”, 13),

“stone”: items(“Stone”, “used for crafting”, “none”, 23),

“grass”: items(“Grass”, “used for rope making”, “none”, 0),

“rope”: items(“Rope”, “can be used for making tools”, “scratches holder”, 123),

“knife”: items(“Knife”, “used for cutting grass”, “can accidentally cut user”, 150),

}

submitted by /u/Acceptable_Novel1564
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *