mruane 0 Junior Poster in Training

Well, I took everyone's advice and used classes. It does work a lot better. I even added a gang war to the demo, but, your gang wins with one turn. I am including the code for the gangfight() function and all necessary classes so if anyone sees the problem, let me know so I can fix it.

# player class

class player():
	hp = 25
	cash = 500
	dealers = 2
	gang = 5
	guns = 0
	ganghp = 20
class hawksgang():
	ganghp = 25
	members = random.randrange(4, 10)
def gangfight():
	charhp = player.ganghp * player.gang
	thughp = hawksgang.ganghp * hawksgang.members
	print "The Hawks gang is attacking you!"
	print "Your gang: ", player.gang
	print "Hawks gang: ", hawksgang.members
	
	# player gang attacks
	
	chardmg = random.randrange(2) + 1
	attack = chardmg * player.gang
	print "Your gang attacks the Hawks!"
	print "You deal ", attack, "damage!"
	
	thughp -= attack
	print 
	print "Your gangs HP: ", charhp
	print "Hawks HP: ", thughp
	
	# hawks attack
	
	thugdmg = random.randrange(1) + 1
	attack = thugdmg * hawksgang.members
	print "The Hawks attack you!"
	print "They deal ", attack, "damage to your gang!"
	
	charhp -= attack
	print "Your gangs HP: ", charhp
	print "Hawks HP: ", thughp
	
	raw_input()
	if charhp < 1:
		print "The hawks have defeated your gang."
		print "Game Over."
		gameover()
	else:
		print "Your gang has defeated the Hawks!"
		cearn = random.randrange(10, 25)
		income = cearn * hawksgang.members
		print "You earned $", income ,"!\n"
		player.cash += income
		return

Now, I am a …

mruane 0 Junior Poster in Training

I have never had a problem with declaring globals like this before. I have tried and tried to come up with a fix, but, to no avail. which is why I came here, as a last resort. Does anybody have an idea of how to fix this?

mruane 0 Junior Poster in Training

It just doesn't do what it is supposed to.

It is supposed to function like this:

1. user chooses to sell an item
2. game removes item from inventory
3. game adds resulting cash to inventory.

here is the offending code:

def foo_sell():
	global cash, dealers
	clear()
	print """\
	
	Sell how many DEALERS?
	
	a. 1 dealer for $50
	b. 2 dealers for $100
	c. 3 dealers for $150
	
	or:
	
	d. exit
	"""
	x = raw_input("> ")
	if x == 'a':
		if dealers > 1:
			print "You sell 1 dealer  for $50."
			dealers = dealers - 1
			cash = cash + 50
			foo_sell()
		else:
			print "You do not have enough dealers to sell."
			print 'You have ', dealers, ' dealers to sell.'
			foo_sell()
	elif x == 'b':
		if dealers > 2:
			print 'You sell 2 dealers for $100.'
			dealers = dealers - 2
			cash = cash + 100
			foo_sell()
		else:
			print "You do not have enough to sell 2 dealers."
			print "You have ", dealers, " dealers to sell."
			foo_sell()
	elif x == 'c':
		if dealers > 3:
			print 'You sell 3 dealers for $150.'
			dealers = dealers - 3
			cash = cash + 150
			foo_sell()
		else:
			print 'You do not have enough to sell 3 dealers.'
			print 'You have ', dealers, ' dealers to sell.'
			bob_sell()
	elif x == 'd':
		cleveland()
mruane 0 Junior Poster in Training

forgot the .py... but it won't let me add it. sorry...

mruane 0 Junior Poster in Training

Okay, I am writing a dopewars clone/wannabe in python. I have it pretty much the way I want it, except that selling items does not work. Buying them does fine, it is just selling them.

Here is the code:

#!/usr/bin/env python
#
#       pimp.py
#       
#       @authors: KarimRuan, 
#       Copyright 2009 
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.
import sys, os
import random

global cash
cash = 500
global dealers
dealers = 2
global hp
hp = 25
global gang
gang = 1
global guns
guns = 0

global thugHP
thugHP = 20


def la_prompt():
	print """COMING SOON"""
	return

def la():
	clear()
	global cash, dealers, hp, gang
	print "CASH: ", cash,  "dealers: ", dealers, "HP: ", hp, "GANG MEMBERS: ", gang
	print
	print 'you are in Los …
mruane 0 Junior Poster in Training

Can you tell me where this unassigned global is...I looked everywhere but cannot find it.

global gold
gold = 0
global a_gold_a
a_gold_a = 15
global a_gold_b
a_gold_b = 15
global a_gold_c
a_gold_c = 20
global room1_done
room1_done = 0

def prompt_main():
    global a_gold_a, a_gold_b, a_gold_c, room1_done
    x = raw_input("What do you search? ")
    if x == "couch":
        if a_gold_a == 15:
            a_gold_a = a_gold_a - 15
            gold = gold + 15
            print "You found 15 gold."
            if gold == 50:
                room2()
            else:
                prompt_main()
        else:
            print "There is no more gold in this couch."
            prompt_main()
    elif x == "newspaper":
        print "There is no gold under this newspaper."
        prompt_main()
    elif x == "painting":
        if a_gold_b == 15:
            a_gold_b = a_gold_b - 15
            gold = gold + 15
            print "You found 15 gold behind this painting. How wierd!"
            if gold == 50:
                room2()
            else:
                prompt_main()
        else:
            print "There is no gold anywhere near this painting."
            prompt_main()
    elif x == "lamp":
        print "Nope. No gold by this lamp."
        prompt_main()
    elif x == "desk":
        if a_gold_c == 20:
            a_gold_c = a_gold_c - 20
            gold = gold + 20
            print "You found 20 gold in the desk drawer!"
            
def Main():
    global gold
    print "Your current gold is... ", gold
    print """You are in a large room. You need to find 50 gold to leave this room.
There is a COUCH with a NEWSPAPER on it. There is a PAINTING hanging on the wall
with a picture of a racoon. A LAMP sits on a …
mruane 0 Junior Poster in Training

I ask the user in my program to enter up to four types of income, with 0 filling the unused income slots. Then, the program is supposed to add up the incomes. It goes like this:

user defines values for incomes 1, 2, 3 and 4.
Program adds together the values of incomes 1, 2, 3 and 4.
Then it prints the calculation result to the screen.
Instead, it just repeats the variable that the user sets for incomes 1, 2, 3 and 4, and prints them in a long string, so if the values were each set to 500, it would print:

500500500500.
What am I doing wrong?

Here is the source code:

def clear():
    print """













"""
def Main():
    x = raw_input("# ")
    if x == "calc" or x == "calculate":
        calculate()
    elif x == "convert":
        clear()
        print "Convert not implemented yet."
        

def calculate():
    x = raw_input("Choose calculation type: ")
    if x == 'money':
        money_calc()
    elif x == 'budget':
        budget_calc()
    elif x == 'grades':
        grades_calc()
    else:
        clear()
        print """Your only options within the calculate function are:

                    'money' , 'grades', and 'budget'.

                    """
        calculate()

def money_calc():
    clear()
    print """Choose your calculation type:

        a. adding income      b. adding expenses  c. calculate total left over income after expenses
        """
    
    x = raw_input("Please choose a, b, or c: ")
    if x == 'a' or x == 'a.':
        clear()
        add_income()
    elif x == 'b' or x == 'b.':
        clear()
        add_expenses()
    elif x == 'c' or …
mruane 0 Junior Poster in Training

No problem. I will definitely take a look at doing things that way, anything to shorted up my code, and make it more effective. The main goal is to quickly create a study partner to help me prepare for the exams. Thanks a lot, everyone, you have helped me out enormously!

mruane 0 Junior Poster in Training

Thanks for all of the advice guys, I actually put a a little of what each of you said into one method. An A+ exam is what you take to show that you have a good knowledge of how to troubleshoot computers, from a hardware and software perspective. If you pass your A+ exams, you become A+ certified. I am pretty sure you need to pass with a 95% or higher, which makes me nervous as if I fail, I have to pay to take the test again, which is like 186 USD each time.

Anyways, here is the start of my code, it just has 14 basic questions, but it gives an idea of where I am going with it. Maybe this code could help others who may be preparing for their A+ exams.

import sys, os

global score
score = 0
def clear():
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print
    print

    
    
q1 = """What is the Binary number system"""
a1 = """The Binary number system is a number system that uses only the numbers 1 and 0, where 1 represents "on",
  and 0 represents "off"."""
q2 = """Explain how the CPU uses the Binary number system."""
a2 = …
mruane 0 Junior Poster in Training

I am preparing for my a+ exams, and am turning all of my notes into a test. I plan on doing this in python, of course. But, I am a little lost at what would be best. Should I create each question as a specific function, calling the next question function when i am done with that question? Or should I create one function to handle the questions, and functions for everything else? My plan for the format of the test is such:

present the question.
prompt the user to press enter when ready for answer
user presses enter
clear screen and begin again

this will go until there are no more questions left to ask, in which case the screen will clear and ask if you want to study again or quit.

thank you for your help.

mruane 0 Junior Poster in Training

Have you contacted tomtelaw?
He was in Pygame business and I think he can help alot. I cannot join this for now, I have alot to do, but wherever I will be able to add anything, I will. Good luck with your project and.....Good idea :)

No I haven't, but thanks, I will contact him!

mruane 0 Junior Poster in Training

I am hoping to create a pixel based rpg game with the story depth of the elder scrolls series, with graphics similar to PixelMan 3 by pymike, (pygame.org/project/712/). If anyone is interested in helping, let me know! I am a basic level python programmer, so am using this project as an opportunity to learn to use pickle(), binascii module, and other things related to gaming. The goal is to produce a game for the Daniweb python community that we could all call our own, and possible enter it into a contest on pygame???? who knows. if you are interested, either respond to this thread or PM me. All level programmers are welcome, including you vega seat!

mruane 0 Junior Poster in Training

I am trying to use binascii to convert this:

town1 = """
++++++++++++++++++++++++++++++++++++
+-------------------------------------------------------------+
+----------H-----------H----------H---------H--------------+
+----------&---------------&---------------------------------+
+------------------------------------------------------------>+
+----------------@-------------------------------------------+
++++++++++++++++++++++++++++++++++++
"""

into the type of graphics used in PyMike's PixelMan 3, found at pygame.org. I looked at the document on python.org telling about binascii and a little bit about how to use it, but since it wasn't presented in a matter that was directed towards gaming, I found it hard to understand. If anyone could, give me a break down of how I would convert town1 as well as the text-mode representations of H (for a house), @ for the player, and & for an NPC into pixel based graphics using binascii. I have the source code for PixelMan 3, and am working with that, but do not understand much of PyMike's code, and it is not very documented (no comments.) here is the PixelMan 3 code, if somebody could insert comments telling me what each section does I would greatly appreciate it.

#! /usr/bin/env python

# Pixelman 3 - PyMike's Entry for Ludum Dare 11
# Copyright (C) 2007  PyMike
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; …
mruane 0 Junior Poster in Training

Thank you Ene Uran, as always, you have been a great help!

mruane 0 Junior Poster in Training

Thanks guys. I will try to get c++ for dummies. I am having trouble though, I can't even get the hello world program to work. I got it right in c#, but I get an error. I double checked my code against the tutorial, and tried other tuts, but still, can't get it to build right. I will post the code later, and see if you guys find any errors, cuz I sure can't. That is a major discouragement, getting caught up in a simple hello world program, and having problems.

mruane 0 Junior Poster in Training

Thanks, I should be able to mess around with this code to make it do what I want. I appreciate the help, all of you guys!

mruane 0 Junior Poster in Training

I would like to use pickle() to save the stats, progress, and location of a player in my text adventure. I know that pickle() write an object to a text file, and that file can be later recalled to load the information.
My curiosity is, would I be able to save the stats, inventory and last location of the player by pickling into one file? If so, how would I do this? I am not quite sure how to use pickle(), so if anyone has any spare source codes where they used pickle() which I could learn from it would be greatly appreciated. Also, would I have to create one object containing all of this information in order to pickle what I need?
And for refreshment, what is an object? I am going to go back through my tutorials to brush up on key terms and concepts, in the meantime. Thanks,
karim

mruane 0 Junior Poster in Training

Woooee, that code worked, it got my dungeon created perfectly. Now, say I wanted to insert the player '@' into the middle of all this, how would I do this? I usually used the thing where I placed him in the 3rd string in the list, but I don't know how that would work with your code? Any suggestions?

The basis of what I am doing is trying to create one small dungeon that will allow for the following events:

fighting monsters
talking to NPC's
moving around

Inventory and such will not be implemented until I understand how to complete the following above actions. I am trying to create a roguelike for the Python members of DaniWeb, just a little gift for everyone who has helped me out with my codes.

mruane 0 Junior Poster in Training

Hi, I am trying to create a simple roguelike-like, a game with graphics similar to roguelikes, with a few extra twists. I am trying to create a dungeon using a list, here is the code...

background = ['#', '#', '#', '#', '#', '#', '#', '#', '#' /n/
              '#', '.', '.', '.', '.', '.', '.', '.', '#' /n/
              '#', '.', '.', '.', '.', '.', '.', '.', '#' /n/
              '#', '.', '.', '.', '.', '.', '.', '.', '#' /n/
              '#', '.', '.', '.', '.', '.', '.', '.', '#' /n/
              '#', '.', '.', '.', '.', '.', '.', '.', '#' /n/
              '#', '.', '.', '.', '.', '.', '.', '.', '#' /n/
              '#', '#', '#', '#', '#', '#', '#', '#', '#' ]
print background

My problem is that it does not work. I am trying to use '#' for walls, and '.' for the ground. I figured that with using /n/ it would make a raw list, but it doesn't work. Without the /n/, the code just prints to the screen in a jumbled, two line mess. Any suggestions on making this work?

Karim.

mruane 0 Junior Poster in Training

Hi all, my name is Karim, and I am migrating from Python to C++ in order to make windows and linux based games. I am using the Visual C++ IDE, and am a complete newbie when it comes to C/C++. Python is so overly simplified that it does not provide a great background when learning C/C++. Well, with my goals in mind, could anyone point me to some *free* online resources for learning to program in C++? Thank you.

mruane 0 Junior Poster in Training

Just a few questions...

1) is C# and visual C# the same language? I downloaded the Visual C# IDE from microsoft, looking to be able to make my own programs using c#.
2) If they are the same, where do I find tutorials to learn to use the language?
3) After having written my first program, and building it, how to I execute the program. In python, you just click on 'run' and it compiles and executes the code for you. Since I am using Visual C#'s IDE, any help specific to that IDE would be greatly appreciated.

I can be reached at karimruan@gmail.com if any of these answers might violate the terms of this forum. Thank you for your help,

karim.

mruane 0 Junior Poster in Training

What do you do after you install Active Perl? I just recently installed it, and did not find an IDE or anything, maybe after he installs it he will have the same problem. How would we get to the actual programming. Would you just open a text editer, write your code, and then save it as a .pl? If so, how do you execute it? I believe in linux you just run it through the command line, but what about windows?

mruane 0 Junior Poster in Training

I just downloaded ActivePerl, hoping it was some kind of IDE for perl. I run windows XP service pack 3 on this box. My Linux Box has perl already installed, but I want to use perl on my windows box as well.
I know nothing about perl, so do I just write a .pl file and execute it somehow, or is there a compiler or IDE such as in C or Python?

Many thanks ahead of time,
mruane.

mruane 0 Junior Poster in Training

Thank you, I will play around with that. I still wonder what is wroong with this code,
in prompt_market_main(),

if prompt == 'look':

doesn't function.
this is basically what it is:

def prompt():
    global begger
    more = raw_input('What do you do? ')
    if more == 'look':
        if begger == 1:
            print "The begger is alive"
        elif begger == 0:
            print "the begger is dead."
     elif more == 'kill beggar':
            print "You kill the begger."
            begger = begger - 1
            prompt()

I have gotten the code to work by itself, in another program, but can't find the problem in the code posted above. When you kill the begger, and look, it still shows him as alive.

NOTE: The code i just posted is only an example, the problem code is in a previous post in this thread.

mruane 0 Junior Poster in Training

Okay, I will keep that in mind. Another problem is that after market_petoria() it should go like this:

look around:

"There is a beggar here, drinking a beer."

kill beggar:

you kill the beggar

look around:

There is a dead begger here.

I set the global begger to 0 when you kill the beggar,

and if beggar == 0 it should print "The begger is dead" after user types look around.
But, it doesn't show that the beggar is dea,d he is still drinking his beer.
What is going on? Am I using globals wrong?

mruane 0 Junior Poster in Training

Thank you jlm699, I will keep that in mind. I have fixed the spelling errors. The biggest concern now though is that after you type in 'done' or 'i am done', you are just in the market place. In this function, at least market_petoria or below, when you look around, you see the begger is holding a beer. When you kill the begger, and type look around, it doesn't say that the begger is dead, as my code says it should.

I think the problem is with the way I use the globals. Can someone look at this code and tell me what I should do to fix it, or at least give me some advice on how to make it better?

mruane 0 Junior Poster in Training

Thank you for the help. I will change my source code. As for the spelling errors, My 14 year old brother wrote most of the story line, and after I realized that he wasn't that good, (plus my teacher wants me to write the WHOLE thing), I fired him. I have to yet fix all the errors. Thank you for all the help.

karim abu NuH

mruane 0 Junior Poster in Training

basically, after the tutorial ends (The user types in 'done' or 'i am done', the command 'kill begger' doesn't work.
The goal is to be able to kill the begger global, and when the player next views the room description, it shows that the global begger has been killed.

For example;

(user types 'look')

there is a begger here with a beer.

(user types 'kill begger')
(user types 'look')
there is a dead begger here. A beer is by his hand.

Does this make more sense? if you run the code you will see that the kill begger command only repeats the function called by 'look' command.

mruane 0 Junior Poster in Training

I am working on a text adventure for my cis class. Just to let you know, the code is graphic, and may be offensive to those who might be a begger LOL. Anyways, my functions do not seem to work properly. I looked over them, they seem fine. where am i going wrong?
here is the code...it's alot.

# My goal is to make the most in-depth text adventure
# possible, where as much of the game world is interactive
# as possible. I plan to have butterfly catching, swimming races,
# jobs, schools, etc.
# I hope for this game to be a text based simulation of life.

######################################### SET THE GLOBALS ########################################################

global shoes
shoes = 0
global underwear
underwear = 0
global bottoms
bottoms = 0
global tops
tops = 0
global bags
bags = 0
global cellphones
cellphone = 0
global laptops
laptops = 0
global daggers
daggers = 0
global faith
faith = 100
global pens
pens = 0
global baseball_bat
baseball_bat = 0
global cars
cars = 0
global cash
cash = 1000
global guns
guns = 0
global houses
houses = 1
global hats
hats = 0
global sunglasses
sunglasses = 0
global earrings
earrings = 0
global tvs
tvs = 0
global tables
tables = 0
global fridges
fridges = 0
global stove
stove = 0
global sink
sink = 0
global movie_player
movie_player = 0
global food
food = 100
global bookshelves
bookshelves = 1
global books
books = …
mruane 0 Junior Poster in Training

Okay, I fixed it a little bit. But it seems like I always lose. I set the global hp to 10, and it still lost. Is it not registering when the monster gets hit? Also, it seems like it is taking more that one turn at a time. Usually, it prints:
You hit the monster
you miss

then the monster take like five turns.
here is the new code:

import random
import sys

global monster_hp1
monster_hp1 = 5
global hp
hp = 10

def init_game():
    print """Welcome to NayNay's Quest"""
    main()
def main():
    global monster_hp1, hp
    print """You are in a fight
    type 'h' to fight """
    x = raw_input(': ')
    if x == 'h':
        while True:
            if your_turn():
                break
            if monster_turn1():
                sys.exit(0)
        else:
            print "Error"

def your_turn():
    global monster_hp1, hp
    hit_miss = random.randrange(0, 2)
    if hit_miss == 1:
        print "You hit the monster!"
        monster_hp1= monster_hp1 = -1
        if monster_hp1 == 0:
            print "You win"
            return True
        else:
            print "You missed."
        return False

def monster_turn1():
    global monster_hp1, hp
    monster_hit= random.randrange(0, 2)
    if monster_hit == 1:
        hp = hp -1
        if hp == 0:
            print "The monster killed you!"
            print "game over"
            init_game()
            return True
        else:
            print "The monster missed"
        return False
    main()

init_game()

Now what is wrong. Also, any suggestions on how to improve my code? I just want to get the battle sequence right before I use it in my game.

mruane 0 Junior Poster in Training

Okay, it still does the same thing, only this time the error log reads:
Traceback (most recent call last):
File "C:/Python25/howtofight.py", line 49, in <module>
main()
File "C:/Python25/howtofight.py", line 19, in main
sys.exit(0)
SystemExit: 0

This is how the battle is supposed to go...

1 press h to fight
user presses h
they hit or miss
monsters turn
monster hits or misses
your turn
user presses h to fight
repeat until one of you is dead.


Should I create a seperate function for when it is your turn again and you must press h? And, what is wrong with my code that it exits at the end of the program?
sys.exit is set to 0, so it shouldn't exit, right?

mruane 0 Junior Poster in Training

Well, that solved one problem, now I get a loop of you hit the monster/you missed the monster/ the monster hit/missed you. It goes on for a while and the ends the program. I checked my function calls and couldn't see the problem. It is probably so easy it's staring me right in the face without me knowing it.
here is the code now:

# adding to christ o'leary's fight function
# to have integer returned use
# x = random.choice([0, 1])
# print x, type(x) # testing

# or x = random.randrange(0, 2)
# print x, type(x)
import random

global monster_HP1
monster_JP1 = 5
global hp
hp = 20

def main():
    global monster_HP1
    monster_HP1 = 5
    global hp
    hp = 10
    print """you are in a fight!
    Type 'h' to fight"""
    x = raw_input(': ')
    if x == 'h':
        fight_unicorn()
    else:
        print "Error"
        main()
        
def fight_unicorn():
    global monster_HP1
    global hp
    hit_miss = random.randrange(0, 2)
    # print x, type(x)
    if hit_miss == 1:
        print "You hit the monster!"
        monster_HP1 = monster_HP1 - 1
        if monster_HP1 == 0:
            print "You win!"
        else:
            monster_turn1()
    else:
        print "You Missed"
        monster_turn1()
def monster_turn1():
    global monster_HP1
    monster_HP1 = 5
    global hp
    hp = 20
    monster_hit = random.randrange(0, 2)
    # print x, type(x)
    if monster_hit == 1:
        print "You are hit!"
        hp = hp-1
        if hp == 0:
            print "Game Over"
    else:
        fight_unicorn() # Chris added this for me
        print "The monster missed"
        fight_unicorn()
main()
mruane 0 Junior Poster in Training

Hey all, i am trying to write a javascript inside an html table which will create an image slideshow which fills the table with each image. Not sure how to implement this as I do not know javascript. Could this be done in plain HTML without loading another page?
Any help would be greatly appreciated.

mruane 0 Junior Poster in Training

I have decided that a text adventure would be better for me to learn from, as a visual game is confusing to me still. So, I was reading Chris O'leary's post about his text adventure game, Advent House, and got many ideas from there. I want to perfect his battle sequence though.
Here is the code he used with minor adjustments on my part in the random module. If someone could tell me where I am going wrong and give me an example I would greatly appreciate it!

# adding to christ o'leary's fight function
# to have integer returned use
# x = random.choice([0, 1])
# print x, type(x) # testing

# or x = random.randrange(0, 2)
# print x, type(x)

def main():
    global monster_HP1
    monster_HP1 = 5
    global hp
    hp = 10
    print """you are in a fight!
    Type 'h' to fight"""
    x = raw_input(': ')
    if x == 'h':
        fight_unicorn()
    else:
        print "Error"
        main()
        
def fight_unicorn():
    global monster_HP1
    global hp
    hit_miss = random.randrange(0, 2)
    print x, type(x)
    if hit_miss == 1:
        print "You hit the monster!"
        monster_HP1 = monster_HP1 - 1
        if monster_HP1 == 0:
            print "You win!"
            master_bedroom()
        else:
            monster_turn1()
    else:
        print "You Missed"
        monster_turn1()
def monster_turn1():
    monster_hit = random.randrange(0, 2)
    print x, type(x)
    if monster_hit == 1:
        print "You are hit!"
        hp = hp-1
        if hp == 0:
            print "Game Over"
    else:
        print "The monster missed"
        fight_unicorn()
main()
mruane 0 Junior Poster in Training

I have been looking for ways to call images and to move them around the screen, but I see many different ways exist. What is the best way to call images?
And, does it matter where the image is? If the images filepath is usr/bin/local/sprite_fantasy
will that affect how I call the image?

mruane 0 Junior Poster in Training

i do not understand pygame or how to use it.

mruane 0 Junior Poster in Training

I plan to write a detailed rogue like in python. But first, I have a few questions...
how do i get started:

how to make the screen
how to make the maps
how to make the main character move when you press a key
how to make it saveable

if anyone can give me code examples for this that would be great.
Also, has anyone written a python roguelike before?

thanks ahead of time.

mruane 0 Junior Poster in Training

Is there a way to make a value a global, after the user has modified it? It would be nice for me to have these two major functionalities, User Defined Charector Names, and the ability
to save the progress when they are done. I guess the two go hand in hand. I have thought about having python take a snapshot, but, intelligence actually possessed my body for a brief moment, and realized I wasn't trying to get a boring photo of text.

mruane 0 Junior Poster in Training

Thanks woooee. Thant helps.

mruane 0 Junior Poster in Training

I have been trying to figure out how to create a custom save script for text games and a text editor that I am working on. I was thinking I would have to have the script write to the actual program, unless I had an extra file just for saves. Which would be the best route, if any of these two at all?

mruane 0 Junior Poster in Training

When I execute the program (just to test my progress), it returns an infinite loop
(i think of main() or enter(). I am posting the entire source code here, maybe somebody could help me better organize it. In hte future, I would like to add a save feature. This is not going to be what it seems like at first, for more on what i am trying to do, just ask.

# program and theme developed by Matthew Ruane
# for ThemApples Development Uninc.
# this is the main file, the first one to load.
#file name=textual.py
 
 
 
 
 
 
 
 
 
 
def gender_prompt():
    gender_prompt == lower.raw_input("Are you Male, Female, or Both?")
    if gender_prompt == 'm'or'male':
        print "You have been registered as a Male. Now for step two!"
        pick_name_male()
        import male
    elif gender_prompt == 'f' or 'female':
        print "You have been registered as a Female. Now for step two."
        pick_name_female()
    elif gender_prompt == 'b'or 'both':
        print "You have been registered as a Hermaphrodite, Both male and female."
        pick_name_both()
    else:
        print ""
        print ""
        print ""
        print ""
        print "You must enter your gender to proceed. Either type Male, Female, or Both."
        print ""
        print ""
        gender_prompt()
                                
 
 
 
 
def create_gender():
    print ""
    print ""
    print ""
    print ""
    print ""
    print ""
    print "Welcome to the Profile Creator registration process."
    print "I will take you through three easy steps to get into"
    print "the Textual Encounters world."
    print ""
    print ""
    print "First, you will need to pick your gender."
    print "You have three choices: …
mruane 0 Junior Poster in Training

that answers my first question, thanks! I actually just want to make ANY graphical game in python. I like the challenge of making an ansi game with a little more animation to it. Instead of your charector being represented by an @, it could be more like this:

telnet towel.blinkenlights.nl

to see a version of start wars in asci. I was thinking of making a game more like that, maybe try to get BETTER even than that!

For those who may not know how to use telnet,

start
run
type "command"
(ms-dos prompt should come up)
type "telnet towel.blinkenlights.nl"
watch the site that gave me the idea.

/\
|
| that works on my win9x OS, not sure about other WIN OS' dos and telnet commands.

mruane 0 Junior Poster in Training

I am horribly (obssesed?) with writing a visually appealing game (simple) in python. My text adventures didn't appeal to my aufience (family), so I was looking at a tut on making a pac man clone, supposed to be line by line, it seemes choppy. Any ways, here is the code.

#! /usr/bin/env python
import os, sys
import pygame
from pygame.locals import *
from helpers import *
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
class PyManMain:
    """The Main PyMan Class - This class handles the main 
    initialization and creating of the Game."""
    
    def __init__(self, width=640,height=480):
        """Initialize"""
        """Initialize PyGame"""
        pygame.init()
        """Set the window Size"""
        self.width = width
        self.height = height
        """Create the Screen"""
        self.screen = pygame.display.set_mode((self.width
                                               , self.height))
                                                          
    def MainLoop(self):
        """This is the Main Loop of the Game"""
        
        """Load All of our Sprites"""
        self.LoadSprites();
        """tell pygame to keep sending up keystrokes when they are
        held down"""
        pygame.key.set_repeat(500, 30)
        
        """Create the background"""
        self.background = pygame.Surface(self.screen.get_size())
        self.background = self.background.convert()
        self.background.fill((0,0,0))
        
        while 1:
            for event in pygame.event.get():
                if event.type == pygame.QUIT: 
                    sys.exit()
                elif event.type == KEYDOWN:
                    if ((event.key == K_RIGHT)
                    or (event.key == K_LEFT)
                    or (event.key == K_UP)
                    or (event.key == K_DOWN)):
                        self.snake.move(event.key)
                        
            """Check for collision"""
            lstCols = pygame.sprite.spritecollide(self.snake
                                                 , self.pellet_sprites
                                                 , True)
            """Update the amount of pellets eaten"""
            self.snake.pellets = self.snake.pellets + len(lstCols)
                        
            """Do the Drawging"""               
            self.screen.blit(self.background, (0, 0))     
            if pygame.font:
                font = pygame.font.Font(None, 36)
                text = font.render("Pellets %s" % self.snake.pellets
                                    , 1, (255, 0, 0))
                textpos = text.get_rect(centerx=self.background.get_width()/2)
                self.screen.blit(text, textpos)
               
            self.pellet_sprites.draw(self.screen)
            self.snake_sprites.draw(self.screen)
            pygame.display.flip()
                    
    def LoadSprites(self): …
mruane 0 Junior Poster in Training

I just want to make an ANSII game, don't need to be in dos, I was actually thinking of creating my own console program for ANSII games, like having an ANSII nintendo on my computer....I really want to make in-depth ANSII games, to overcome the same challenges programmers had with a text-mode computer when making games. I thought of creating a diablo one style game, ansii of course, full screen, with the best ansii graphics ever seen. I mean take a long time on it. I am just unsure wear to begin, I have only made text adventures, I am unsure of where to even begin. Any starters or ideas or links to topic specific tutorials would be great! Thanks.

mruane 0 Junior Poster in Training

I was wondering, if I wanted to attempt an ANSII dos game in Python, what would be the best way to do it? I would like to know how I would run it, i.e., would it run in the Python Interactive shell or could a make it run in dos?
The only games I ever made in Python were text adventures, but, is it not the same concept?
Just wondering, what would I use? Functions and classes, etc?
If somebody could give me a good starting point, I beilieve that would be enough to get me going. Thank you.

mruane 0 Junior Poster in Training

Yeah, I use WIN 98. As for the Unicode thing, I have no clue. I ended up giving up on the same problem when building websites. I couldn't declare the encoding or something with javascript. I never understood Unicode or what it entails, how to know if I use what, and how to declare it and get it to work.

mruane 0 Junior Poster in Training

hey, thanks for the clarification anyways, la mouche! I can't believe I actually didn't realize that. So, does that mean that I would have to repeat the firends = raw_input? That would reset the definition of friends wouldn't it?

mruane 0 Junior Poster in Training

I like vegaseats Idea for the list usage, but maybe it could be altered alittle bit, say

my_str = weapon # fists default!
my_life = 10
weapon = fists
fists = 1
dagger = 2
short_sword = 3
broad_sword = 5

def battle():

mruane 0 Junior Poster in Training

so i need to use a .py extension then? Is there still a way to run the program anywhere else besides that ugly ms-dos looking client thing?

I changed all my files to .py extensions and now get a new traceback error message:

Traceback (most recent call last):
File "C:/Python24/p2e_test1.py", line 29, in -toplevel-
console = [{"script": 'hateme2prog.py'}] )
File "C:\PYTHON24\lib\distutils\core.py", line 149, in setup
dist.run_commands()
File "C:\PYTHON24\lib\distutils\dist.py", line 946, in run_commands
self.run_command(cmd)
File "C:\PYTHON24\lib\distutils\dist.py", line 966, in run_command
cmd_obj.run()
File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 218, in run
self._run()
File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 285, in _run
self.create_binaries(py_files, extensions, dlls)
File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 500, in create_binaries
self.copy_dlls(dlls)
File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 422, in copy_dlls
self.copy_dlls_bundle_files(dlls)
File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 472, in copy_dlls_bundle_files
self.patch_python_dll_winver(dst)
File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 905, in patch_python_dll_winver
add_resource(unicode(dll_name), data, RT_STRING, id, delete)
RuntimeError: this function requires unicows.dll in the Python directory on Win 95/98/Me

I do not understand what is meant by: requires unicows.dll in the Python directory on Win 95/98/Me,
does this mean that I need to create a folder named unicows.dll containing the p2e_test1.py and hateme2prog.py files (I renamed them)?
I will try that just in case.

EDIT: I actually did see unicows.dll when I ran Python24, went to …

mruane 0 Junior Poster in Training

i thought that by using friends() i could repeat the friends = raw_input(string).

friends = raw_input().lower() # I guess friends() doesn't call this?
    if friends == "yes":
        part_two()
    elif friends == "no":
        print "Yeah I figured that much."
        part_two_a1()
    else:
        print "Come on, it's a yes or no question, DUDE!"
        friends()