Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pokemon in python (beta)
#1
This is a program I made from an idea I had, I will improve the program throughout, any suggestions are appreciated Smile , this is what I have for now.
from tkinter import *
root = Tk()
import time
import random
class e:
 def new_game():
    e.ehealth = 100

class u:
 def new_game():     
    u.money = 110
    u.xp = 0
    u.heal = 100
    u.PP = 12
 def data():
    tex.insert(END,'Золото = '+str(u.money)+',XP = '+str(u.xp)+', Health:'+str(u.heal)+' PP = '+str(u.PP)+'\nEnemy\'s  info: '+str(e.ehealth)+'\n')
 def Plasmabeam():
  if u.PP<=3:
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
     tex.insert(END,'You cannot perform this action since you don\'t have enough PP \n')
  else:
      pass
  u.PP=u.PP-3
  plasmaba=random.randint(20,30)
  tex.insert(END,"Your enemy took damage! "+str(plasmaba)+"-hp\n")
  e.ehealth=e.ehealth-plasmaba
  enemyattack=random.randint(20,80)
  if enemyattack>30:
     tex.insert(END,'Hard hit! -'+str(enemyattack)+'\n')
     u.heal=u.heal-enemyattack
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
  else:
     tex.insert(END,"You took damage! "+str(enemyattack)+"-hp\n")
     u.heal=u.heal-enemyattack
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
  if e.ehealth<=0 and u.heal<=0:
      tex.insert(END,'It is a tie!')
      e.ehealth=100
      u.heal=100
      b1.grid()
      b2.grid()
      b3.grid()
      b4.grid()
      b5.grid()
      b6.grid()
      b10.grid()
      b12.grid_remove()
      b13.grid_remove()
      tex.grid()
  elif e.ehealth<=0:
      u.money=u.money+400
      u.xp=u.xp+2000
      tex.insert(END,'You won! Prize money: 400, XP: 2000, and HP leftover:'+str(u.heal)+' \n')
      e.ehealth=100
      u.heal=100
      b1.grid()
      b2.grid()
      b3.grid()
      b4.grid()
      b5.grid()
      b6.grid()
      b10.grid()
      b12.grid_remove()
      b13.grid_remove()
      tex.grid()
  elif u.heal<=0:
      u.money=u.money+23
      u.xp=u.xp-356
      tex.insert(END,'You lost! money: 23, XP: 356, and HP leftover:'+str(u.heal)+' \n')
      e.ehealth=100
      u.heal=100
      b1.grid()
      b2.grid()
      b3.grid()
      b4.grid()
      b5.grid()
      b6.grid()
      b10.grid()
      b12.grid_remove()
      b13.grid_remove()
      tex.grid()

 def Train():
  train=random.randint(5,25)
  u.money=u.money-40
  u.xp=u.xp+1000
  u.heal=u.heal+train
  tex.insert(END,'You used: 20 coins, You recieved: 1000+ XP, and healed by '+str(train)+'\n')
   
 def IWANTTORUNAWAY():
  Run=random.randint(0,2)
  if Run==1:
   tex.insert(END,"You ran away!\n")
   time.sleep(1)
  elif Run==2:
   tex.insert(END,"You failed to run away!\n")

 def heal():
     u.heal=u.heal+15
     tex.insert(END,'You have been healed by 15+ HP \n')

 def menu():
     b1.grid_remove()
     b2.grid_remove()
     b3.grid_remove()
     b4.grid_remove()
     b5.grid_remove()
     b6.grid_remove()
     b10.grid_remove()
     b7.grid()
     b8.grid()
     b9.grid()
     b11.grid()
     tex.grid_remove()
     root.geometry( '300x300' )
 def continue1():
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b7.grid_remove()
     b8.grid_remove()
     b9.grid_remove()
     b11.grid_remove()
     tex.grid()
     root.geometry( '700x700' )
 def exit1():
     root.destroy()
 def Attack():
     b1.grid_remove()
     b2.grid_remove()
     b3.grid_remove()
     b4.grid_remove()
     b5.grid_remove()
     b6.grid_remove()
     b7.grid_remove()
     b8.grid_remove()
     b9.grid_remove()
     b10.grid_remove()
     b11.grid_remove()
     tex.grid_remove()
     b12.grid()
     b13.grid()
     root.geometry( '300x300' )
 def rematch():
     u.heal=100
     e.ehealth=100
     u.PP=12
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b7.grid_remove()
     b8.grid_remove()
     b9.grid_remove()
     b11.grid_remove()
     tex.grid()
     u.heal=100
     e.ehealth=100
     u.PP=12
 def scratch():
  if u.PP<=2:
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
     tex.insert(END,'You cannot perform this action since you don\'t have enough PP \n')
  else:

        
   u.PP=u.PP-2
   scratcha=random.randint(10,15)
   tex.insert(END,"Your enemy took damage! "+str(scratcha)+"-hp\n")
   e.ehealth=e.ehealth-scratcha
   enemyattack=random.randint(20,80)
  if enemyattack>30:
     tex.insert(END,'Hard hit! -'+str(enemyattack)+'\n')
     u.heal=u.heal-enemyattack
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
     root.geometry( '700x700' )
  else:
     tex.insert(END,"You took damage! "+str(enemyattack)+"-hp\n")
     u.heal=u.heal-enemyattack
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
     root.geometry( '700x700' )
  if e.ehealth<=0 and u.heal<=0:
      tex.insert(END,'It is a tie!')
      e.ehealth=100
      u.heal=100
      b1.grid()
      b2.grid()
      b3.grid()
      b4.grid()
      b5.grid()
      b6.grid()
      b10.grid()
      b12.grid_remove()
      b13.grid_remove()
      tex.grid()
      root.geometry( '700x700' )
  elif e.ehealth<=0:
      u.money=u.money+400
      u.xp=u.xp+2000
      tex.insert(END,'You won! Prize money: 400, XP: 2000, and HP leftover:'+str(u.heal)+' \n')
      e.ehealth=100
      u.heal=100
      b1.grid()
      b2.grid()
      b3.grid()
      b4.grid()
      b5.grid()
      b6.grid()
      b10.grid()
      b12.grid_remove()
      b13.grid_remove()
      tex.grid()
      root.geometry( '700x700' )
  elif u.heal<=0:
      u.money=u.money+23
      u.xp=h.xp-356
      tex.insert(END,'You lost! money: 23, XP: 356, and HP leftover:'+str(u.heal)+' \n')
      e.ehealth=100
      u.heal=100
      b1.grid()
      b2.grid()
      b3.grid()
      b4.grid()
      b5.grid()
      b6.grid()
      b10.grid()
      b12.grid_remove()
      b13.grid_remove()
      tex.grid()
      root.geometry( '700x700' )
   
 def safefile():
     file1 = open("safe file.txt", "w")
     file1.write(+str(u.money)+ '\n'+str(u.heal)+ '\n'+str(u.PP)+'\n'+str(e.ehealth)+'\n')
     file1.close()
     b1.grid()
     b2.grid()
     b3.grid()
     b4.grid()
     b5.grid()
     b6.grid()
     b10.grid()
     b12.grid_remove()
     b13.grid_remove()
     tex.grid()
     root.geometry( '700x700' )
     tex.insert(END,'Data sucsessfully saved')
 def bag1():
     b1.grid_remove()
     b2.grid_remove()
     b3.grid_remove()
     b4.grid_remove()
     b5.grid_remove()
     b6.grid_remove()
     b7.grid_remove()
     b8.grid_remove()
     b9.grid_remove()
     b10.grid_remove()
     b11.grid_remove()
     b12.grid_remove()
     b13.grid_remove()
     b14.grid()
     b15.grid()
     tex.grid_remove()
     root.geometry( '300x300' )
 def Pokeboll():
     pokebollcatch=random.randint(0,100)
     if pokebollcatch<=50:
         b1.grid()
         b2.grid()
         b3.grid()
         b4.grid()
         b5.grid()
         b6.grid()
         b10.grid()
         b14.grid_remove()
         b15.grid_remove()
         tex.grid()
         root.geometry( '700x700' )
         tex.insert(END,'You caught the pokemon! \nHere are your prizes: Money=100, XP=1000. \n')
         u.money=u.money+100
         u.xp=u.xp+1000
         u.heal=100
         u.PP=12
     elif pokebollcatch>=51:
         b1.grid()
         b2.grid()
         b3.grid()
         b4.grid()
         b5.grid()
         b6.grid()
         b10.grid()
         b14.grid_remove()
         b15.grid_remove()
         tex.grid()
         root.geometry( '700x700' )
         tex.insert(END,'You failed to catch the pokemon! \n')

     

 
b1 = Button(root,text="Attack!",width=10,height=2, command=u.Attack)
b2 = Button(root,text="Run!",width=10,height=2, command=u.IWANTTORUNAWAY)
b3=Button(root,text="User info",width=10,height=2, command=u.data)
b4=Button(root,text="Bag",width=10,height=2, command=u.bag1)
b5 = Button(root,text="Train",width=10,height=2, command=u.Train)
b6 = Button(root,text="Heal",width=10,height=2, command=u.heal)
b7=Button(root,text="Continue", width=10,height=2, command=u.continue1)
b8=Button(root,text="Rematch", width=10,height=2)
b9 = Button(root,text="Save", width=10,height=2, command=u.safefile)
b10 = Button(root,text="Menu", width=10,height=2, command=u.menu)
b11=Button(root,text="Exit", width=10,height=2, command=u.exit1)
b12=Button(root,text="Plasma beam", width=10,height=2, command=u.Plasmabeam)
b13 = Button(root,text="Scratch", width=10,height=2, command=u.scratch)
b14 = Button(root,text="Pokeball", width=10,height=2, command=u.Pokeboll)
b15 = Button(root,text="Health spray", width=10,height=2)
tex = Text(root,font="14",wrap=WORD,width=80,height=10)


b1.grid(row=3,column=1)
b2.grid(row=3,column=2)
b3.grid(row=3,column=3)
b4.grid(row=3,column=4)
b5.grid(row=3,column=5)
b6.grid(row=3,column=6)
b7.grid(padx=100,pady=15)
b8.grid(padx=80,pady=15)
b9.grid(padx=40,pady=15)
b10.grid(row=3,column=7)
b11.grid(padx=20,pady=15)
b12.grid(row=3,column=7)
b13.grid(row=3,column=8)
b14.grid(row=1,column=1)
b15.grid(row=1,column=2)
tex.grid(row=2,columnspan=10)

u.new_game()
e.new_game()
root.title( 'Pokemon: Ruby' )   
root.geometry( '700x700' )
b7.grid_remove()
b8.grid_remove()
b9.grid_remove()
b11.grid_remove()
b12.grid_remove()
b13.grid_remove()
b14.grid_remove()
b15.grid_remove()
Quote
#2
Pretty impressive my dude! Keep it up, I'm sure you'll be able to make an awesome game-app.

Maybe you can start working on graphics now and a pokemon spawn system. And maybe even a search mechanic (like picking a spot out of a few other spots to search for a pokemon).
RandomCoder likes this post
Quote
#3
(Jun-12-2018, 01:26 PM)Nwb Wrote: Pretty impressive my dude! Keep it up, I'm sure you'll be able to make an awesome game-app. Maybe you can start working on graphics now and a pokemon spawn system. And maybe even a search mechanic (like picking a spot out of a few other spots to search for a pokemon).
Do you have a Github account? We could work on this together just to make everything easier.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)