Jump to content

  • Log In with Google      Sign In   
  • Create Account


Kurai Tsubasa

Member Since 22 Aug 2013
Offline Last Active Sep 13 2014 02:07 AM

Topics I've Started

What is super().__init()

26 July 2014 - 04:56 AM

Hi,i just found a TMX library but i can't find any tutorial that explain it clearly so i tried to understand the library myself but i don't know what is super().__init__().I already tried to search about it but i don't really understand it,the explaination is to advance for me sad.png  because i'm still new in programming world so this is code:

class Player(pygame.sprite.Sprite):
    def __init__(self, location, orientation, *groups):
        super(Player, self).__init__(*groups)
        self.image = pygame.image.load('sprites/player.png')
        self.imageDefault = self.image.copy()
        self.rect = pygame.Rect(location, (64,64))
        self.orient = orientation 
        self.holdTime = 0
        self.walking = False
        self.dx = 0
        self.step = 'rightFoot'
        # Set default orientation
        self.setSprite()
        

Any helps will be very appreciate and please explain it using easy example biggrin.png if it possible also if you need a full code i will add it since the code is too long.Thank you so much


Help me learn Pygame

21 May 2014 - 11:26 PM

hello, it's been a while since I postedbiggrin.png .i have national exam this early month but it's already over now ^^(i need to study hard to pass the exams so a few month ago i can't open my computer to long but now i have 1 month holiday).So,i think i already know the basics of the python and want to move on to game developing,i tried Invent Your Game with Python book but i feel like it is still hard to understandunsure.png.So i'm looking some book that easy to understand,to read in this holiday or video/tutorial online that can improve both python and pygame.(i really need collision detection and tile map because i only want to make a simple RPG)

 

I already tried(Python):

-New boston video

-byte of python

-learn Python the hard way

-and some web(i forgot the web ^^a)

 

And for pygame i only tried Invent Your Game with Python.Sometimes i feel down because i can't understand what that code dosad.png(but i feel i can't stop trying) .If you have great tutorial to help me or advice i'm really appreciate thatsmile.png.Thank You


OOP is so confusing[wrong question]

10 January 2014 - 05:39 AM

Hi guys i want to know the process of object orientated programming(OOP) i tried my best to understand what is exactly the process but i have no idea what is it.I have a code like this:







class Song(object):

	def __init__(self, lyrics):
		self.lyrics = lyrics
	
	def sing_me_a_song(self):
		for line in self.lyrics:
			print line
			
happy_bday = Song(["Happy birthday to you",
		   "I don't want to get sued",
                   "So I'll stop right there"])	
	   
bulls_on_parade = Song(["They rally around the family",
			"With pockets full of shell"])
						
happy_bday.sing_me_a_song()

bulls_on_parade.sing_me_a_song()

And i don't understand what is "for" and "in" statement it is really confusing me. and i don't understand what :







self.lyrics = lyrics

and 







for line in self.lyric:
        print line

is do for .Sorry for asking to muchunsure.png


[Solved]How to make variable for item[Adventure Text Game]

04 January 2014 - 01:36 AM

Hi everyone biggrin.png i tried to make item in adventure text based game but it seems not working i make the variable for key so when the variable go to number 1 it would open the door but when i tried it.It show me an error : Name:Global name key_work_room is not defined

 

here my script(fixed for global variable):

from sys import exit

global key_work_room

key_work_room = 0

def work_room():
	global key_work_room
	if key_work_room == 1:
		print "There is a book."
		print"""Choices:
		1.Read
		2.Leave
		"""
		
		next = raw_input(">")
		
		if next == "1":
			print """
			Go to the Dark corridor and there is a door that
			keep a magic sword.It can used to kill demon 
			in that door there is a key
			541
			"""
		elif next== "2":
			stair()
		else:
			print "Check your spelling."
			print " "
			work_room()
	else:
			print "Check your spelling."
			print " "	
			work_room()
def bed_room():
	print "there is a key in the desk."
	print """choices:
	1.Take.
	2.leave.
	"""
	
	next = raw_input("> ")

	if next == "1":
		global key_work_room
		key_work_room += 1
		stair()
	
	elif next == "2":
		stair()
	else:
		print "Check your spelling."
		print " "
		bed_room()

def second_floor():
	print "There is so many torch in this room but there is a dark side."
	print """Choices:
	1.Take the torch.
	2.Go to the dark side.
	3.back
	"""
	
	next = raw_input("> ")
	
	if next == "1":
		print "You get the torch"
		torch = 1
		second_floor()
	elif next == "2":
		print "Something lurking in the dark attack you..."
	elif next == "3":
		stair()
	else:
		print "Check your spelling."
		print " "
		second_floor()

def stair():
	print key_work_room
	print "Now you're in the 2nd floor."
	print "There are 4 room."
	print "which one do you choose? or Do you want take a look around?"
	print "1. to look door 1."
	print "2. to look door 2."
	print "3. to look door 3."
	print "4. to look door 4."
	print "5. to look around."
	
	next = raw_input("> ")
	
	if next == "1":
		king_throne()
	elif next == "2":
		bed_room()
	elif next == "3":
		veranda()
	elif next == "4":
		work_room()
	elif next == "5":
		second_floor()
	elif next == "exit":
		exit(0)
	else:
		print "Check your spelling."
		print " "
		stair()
		
def living_room():
	print "you find yourself in living room."
	print "You don't remember anything it looks like something hit your head."
	print "You now fully regain your consciousness."
	print "You start to walking and you found a stair and dark corridor."
	
	next = raw_input("> ")
	
	if next == "stair":
		stair()
	elif next == "dark corridor":
		dark_corridor
	elif next == "exit":
		exit(0)
	else:
		print "Check your spelling."
		print " "
		living_room()

def start():
	print "Welcome in Fantasy World."
	print "This is simple game type 'exit' to exit."
	print "choose your destination by type the destination name."
	print "Are you boy or girl?"
	character = raw_input("> ")
	
	if character == "boy" in character or "girl" in character:
		living_room()
	elif character == "exit":
		exit(0)
	else:
		print "Check your spelling."
		print " "
		start()

def dead():
	print "you died and the mystery still uncovered."
	print """Choices:
	1.Play again
	2.Take a rest.
	"""
	choice = raw_input("> ")
	
	if choice == "1":
		start()
	elif choice == "2":
		exit(0)
	else:
		print "Check your spelling."
		print " "
		dead()

start()

it haven't finished yet but i need key to know how make the variable for item work also if you find anything weird in my script please tell mesmile.png .Thank youbiggrin.png


exercise 35 error after play the game

28 December 2013 - 06:12 AM

I already reach the exercise 35 learnpythonthehardway and i think it is really fun making an adventure text game.But i got some error after playing it.I tried to figure it out but i thing there is nothing wrong :

 

File "C:\Documents and Settings\User\My Documents\Notepad++\Project\ex35.py",
line 76, in <module>
start()
File "C:\Documents and Settings\User\My Documents\Notepad++\Project\ex35.py",
line 69, in start
bear_room()
File "C:\Documents and Settings\User\My Documents\Notepad++\Project\ex35.py",
line 37, in bear_room
gold_room()
File "C:\Documents and Settings\User\My Documents\Notepad++\Project\ex35.py",
line 16, in gold_room
dead("You good greedy bastard!")
File "C:\Documents and Settings\User\My Documents\Notepad++\Project\ex35.py",
line 59, in dead
exit(0)
SystemExit: 0

 

That is a bunch of error i wonder what is wrong with my script.I can run it perfectly fine.

 

here my script:

 

from sys import exit

def gold_room():
print "This is full of gold. How much do you take?"

next = raw_input("> ")
if "0" in next or "1" in next:
how_much = int(next)
else:
dead("man,learn how to type a number.")

if how_much < 50:
print "nice you're good greedy,you win!"
exit(0)
else:
dead("You good greedy bastard!")


def bear_room():
print "There is a bear here."
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move the bear?"
bear_moved = False

while True:
next = raw_input("> ")

if next == "take honey":
dead("The bear looks at you then slaps your face off.")
elif next == "taunt bear" and not bear_moved:
print "The bear has moved from door."
bear_moved = True
elif next == "Taunt bear" and bear_moved:
dead("The bear gets pissed off and chews your leg off.")
elif next == "Open door" and bear_moved:
gold_room()
else:
print "I got no idea what that means."


def cthulhu_room():
print "Here you see the great evil Cthulhu."
print "He, it, whatever stares at you and you go insane."
print "Do you flee for your life or eat your head?"

next = raw_input("> ")

if "flee" in text:
start()
elif"head" in next:
dead("Well that was tasty!")
else:
cthulhu_room()


def dead(why):
print why,"Good job!"
exit(0)

def start():
print "You are in a dark room."
print "there is a door to your right and left."
print "Which one do you take?"

next = raw_input("> ")

if next == "left":
bear_room()
elif next == "right":
cthulhu_room()
else:
dead("You stumble around the room until you starve.")


start()

 

And there is something i want to ask,what is int() do? and why the code is written from backward but when i tried put the def start(),def cthulhu_room,def bear_room,def dead,and def gold room it still work.Are def can be place anywhere so it doesn't matter where you put it,if it in ends or first or it may make some bugs that i didn't notice?

Thank you so much your answer is really appreciated it.biggrin.png


PARTNERS