Hi I am 13 and I have been programming for 1 1/2 yrs now (since 12 yrs old is what I really mean). I need some advice on how to make your character move with keyboard without any packages or pygame. I need the character to actually move in the map I have create with the special character keys and stuff, I also need help with creating a menu system so that it actually launches the game. Here is my code.
class Map(self, keyboard):
""" View of characted being moved to new location. """
class Character():
def Character(object):
C = player(hero)
hero = {'name' : 'Hero',
'lvl' : 1,
'xp' : 0,
'lvlNext' : 25,
'stats' : {'str' : 1,
'dex' : 1,
'int' : 1,
'hp' : 30,
'atk' : [5, 12]}}
def update(self, C, map):
""" Move player based on keys pressed. """
if keyboard.is_pressed(K_w, C, map):
self.C
self.map
self.y -= 1
if keyboard.is_pressed(K_s, C, map):
self.C
self.map
self.y += 1
if keyboard.is_pressed(K_a, C, map):
self.C
self.map
self.x -= 1
if keyboard.is_preseed(K_d, C, map):
self.C
self.map
self.x += 1
else:
print(" Waiting for your move. ")
class Enemy():
def Enemy(object):
f = enemy(fly)
fly = {'name' : 'Fly',
'lvl' : 1,
'reward' : 25,
'xp' : 0,
'lvlNext' : 25,
'stats' : {'str': 1,
'int' : 1,
'hp' : 30,
'atk' : [5, 12]}}
def move(self, f, map):
""" Move """
class Wall()
def Wall(object):
P = wall(solid)
solid = ['name' : 'Solid',
'Function' :
c = chest
d = door
DD = door
map = """
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
P|-----------------------------------------------------|P
P| |--------| |-------|------------| |---------------|P
P| | |PPDPPPPPPPP| | | |P
P| C| |P P| f | | |P
P| | |P f P| | | |P
P| | |P P| d d |P
P| | |P P| | | |P
P| | |P P| | | |P
P| | |P P| | | cccc |P
P| | |PPPPPPPPPPP| | | c c |P
P|__d_______|P|_________d___________| |____cccc_______|P
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPDDPPPPPPPPPPPPPPPPPP
"""
class Keyboard(self, character, map):
""" Key board controls. """
def update(self):
""" Move hero based on keys pressed. """
if keyboard.is_pressed(K_w, p, map):
self.y -= 1
if keyboard.is_pressed(K_s, p, map):
self.y += 1
if keyboard.is_pressed(K_a, p, map):
self.x -= 1
if keyboard.is_preseed(K_d, p, map):
self.x += 1
hero = {'name' : 'Hero',
'lvl' : 1,
'xp' : 0,
'lvlNext' : 25,
'stats' : {'str' : 1,
'dex' : 1,
'int' : 1,
'hp' : 30,
'atk' : [5, 12]}}
fly = {'name' : 'Fly',
'lvl' : 1,
'reward' : 25,
'xp' : 0,
'lvlNext' : 25,
'stats' : {'str': 1,
'int' : 1,
'hp' : 30,
'atk' : [5, 12]}}
def level(char):
nStr, nDex, nInt = 0, 0, 0
while char['xp'] >= char['lvlNext']:
char['lvl'] += 1
char['xp'] = char['xp'] - char['lvlNext']
char['lvlNext'] = round(char['lvlNext'] * 1.5)
nStr += 1
nDex += 1
nInt += 1
print('level:', char['lvl'])
print('STR {} +{} DEX {} +{} INT {} +{}'.format(char['stats']['str'], nStr,
char['stats']['dex'], nDex,
char['stats']['int'], nInt))
char['stats']['str'] += nStr
char['stats']['dex'] += nDex
char['stats']['int'] += nInt
from random import randint
def takeDmg(attacker, defender):
dmg = randint(attacker['stats']['atk'][0], attacker['stats']['atk'][1])
defender['stats']['hp'] = defender['stats']['hp'] - dmg
if defender['stats']['hp'] <= 0:
print('{} has been slain'.format(defender['name']))
hero['xp'] += fly['reward']
level(hero)
input('Press any key to quite.')
exit(0)
So as you can see what I am trying to do at least. I am needing the map, and the "Game_Sys"
which equals menu, and I need the menu to respond to any key function I have. Now I built the level system it actually works. I built the enemy with reward system to add to my level once I finish killing the enemy, my xp gets filled up else I level up if it gets over my max xp for current lvl. But now I want to move "p = player blablabla"
across map without PYGAME, and without a package. It is text based so hopefully I get this program to run somehow. Anyways, if any see any errors and give me some help and advice on this game thank you. My goal is to get "C" to move around the map I created, and if I get close to f, I get attacked, or i start a battle, and I go from there.
Can I use livewires to open up a game window or do I need pygame for a game window to open? Can I have a partner to help out? I do need someone.