Jump to content
• Advertisement
• entries
7
• comments
2
• views
1009

# first time coding in python on ios: Guess My Number (rated M: language)

708 views

So I used python 3 for ios on my ipad to do part one of this assignment.

Part One: create a guess my number game:

numSpecial = 0
time = 0
guesses = 0
g = 0
i = 0
import random
numSpecial= random.randint(1,9)
print ("guess my nmber, biatch! between 1 and 10")
while g!= numSpecial:
time = time + 1
if time > 5:
print ("you took too long, loser")
elif g > numSpecial:
print ("too high, shithead")
guesses = guesses + 1
elif g < numSpecial:
print ("too low, asshole")
guesses = guesses + 1
elif guesses > 10:
print ("I have had enough of your shit")
else:
print ("you found an error")
g = int(input("what is your guess?"))
if g == numSpecial:
print ("you guessed right, you are not as stupid as I thought.")
i = input ()

Part Two: figure out where in the program the computer recognises time and place a time limit on the game.

And no it doesn't have an ending because I haven't covered ending a program in the text yet.

## Recommended Comments

There are no comments to display.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
• Advertisement
• Advertisement

• ### Similar Content

• I've been working on a simple ASCII sandbox game about survival. The code is very primitive because I just whipped it up in a few hours, but the concept seems like it could be interesting.
It's written in Python and if you want to run it I recommend using either the file enclosed or running the code in 32 bit (It runs very slow on IDLE).
Tell me what you think!
Thanks.
PS : The filename is "MINECRAFT2" because it was based off of my previous attempt at a Minecraft clone.
MINECRAFT2.lnk
Oh, sorry I just realized I posted this in the wrong community.

• Hello all,
essentially what I'm looking for is a flowchart generator that I can leverage with my python applications using, "magic characters" (@) and the like, above flow control structures, and important bits of code. While there does seem to exist some similar libraries in the py eco system, there doesn't seem to be anything 1:1 to what I'm looking for, I've heard of Doxygen, but i'd prefer something native to Python.
Really just something that gives my engineers minimal control of the output of what the flowchart will look like in the most minimally invasive way possible. Also, I know the process for flowcharting is backwards in this proposition, but this is more for management after the fact.
If something exists, great! If not, I'll code it out, but don't want to duplicate efforts if something similar is already out there
Marcus
• By jyscal
Hello
I am trying to create a grid of images in pyglet and python and I am not sure where exactly I am going wrong.
The goal is for it to be a Breakout/Arkanoid clone. The problem I am having is getting the brick images to display in a grid.
Here is the code that as far as I can tell, should place the bricks in the correct position.

class Brick(): def __init__(self, space): # Create the list to hold different sprite bricks and load images self.batch = pyglet.graphics.Batch() self.brick_images = ['brick1.png', 'brick2.png'] self.brick_sprites = [] # 1 out of 5 chance to drop a power pill self.chance_to_drop = 1 # Set the images anchor point to its center and create sprites for i in range(len(self.brick_images)): img = pyglet.image.load(self.brick_images[i]) img.anchor_x = img.width // 2 img.anchor_y = img.height // 2 self.brick_sprites.append(pyglet.sprite.Sprite(img)) for x in range(7): for y in range(7): self.body = pymunk.Body(body_type=pymunk.Body.KINEMATIC) # The position where each pymunk body will be placed self.body.position = x * 100 + 75, y * 30 + 340 self.brick_type = random.randint(0, len(self.brick_sprites) - 1) if self.brick_type == 0: sprite = self.brick_sprites[0] # Set the sprite to the same position as the pymunk body sprite.set_position(self.body.position.x, self.body.position.y) sprite.batch = self.batch elif self.brick_type == 1: sprite = self.brick_sprites[1] sprite.set_position(self.body.position.x, self.body.position.y) sprite.batch = self.batch self.shape = pymunk.Segment(self.body, (0, 0), (50, 0), 6) self.shape.elasticity = 0.80 self.shape.collision_type = collision_types['brick'] space.add(self.body, self.shape) handler = space.add_collision_handler(collision_types['brick'], collision_types['ball']) handler.separate = self.remove_brick
So what I am trying to accomplish is have 7 rows of 7 bricks. As far as I can see the sprites are being created in the loop, but when I run the program only 2 bricks are being displayed. I am sure there is something wrong with the way I am looping but honestly just cannot see where I am going wrong. I have spent some time, trying to see the error but simply cannot see where I am going wrong.
I can see that the pyglet brick sprites are NOT being set to the correct x, y of the pymunk body, even though, using the same formula for the player paddle object lines up the sprite perfectly.

#Set the sprite to pymunk object position self.image = pyglet.image.load('paddle.png') self.image.anchor_x = self.image.width // 2 self.image.anchor_y = self.image.height // 2 self.sprite = pyglet.sprite.Sprite(self.image, x=self.position.x, y=self.position.y)
I am very confused with this one and I just hope I have explained everything clearly enough. Thank you for any help or assistance in any way.

• Hi,
I have an online multiplayer RPG maze game which I built in NodeJS. It is quite simple. Uses socket.io. Single threaded application so I don't have to worry about race conditions such as two users attempting to take the same object at the same time. The client sends in messages, which are processed by the gameserver and alter the player/world state, query the MySQL database, and broadcasting messages to all the other players and also updating things in the MySQL database.
In the last month I have been learning python and I would like to port my game to Python as I think it will be better suited. Doing some research I have found many suggest using Twisted Python so this is the route I am going to take.
I wondered if anyone could give me some suggestions for a basic framework of how I would handle the problem of race conditions when moving to an environment where things are operating in parallel, especially with regard the querying and updating of the state in the MySQL.
If at all possible I wondered if there are any open source implementations of an MMO architecture using Twisted Python that I could look through that dealt with these issues.
Thank you for your time reading this

• I want to make some games. My question is what should my first steps be, besides learning more python and unity2d?
I'm hoping I haven't asked this before.
I thought my first step was conquering enough of unity and python so I can start making small games.
I don't know enough python to build a text-based adventure game just yet.
I haven't really started with unity 2d yet.
I want to make 4 games:
1)  a survival game set in a bubble in New Zealand
2) an rpg battle game about differently-shaped spaceships protecting their resources
3) a hustling game influenced by land of Illusion: starring mickey mouse graphics and hell's kitchen ds mechanics
4) an end of the world game where you play god and mutate heroes to fight the ultimate evil supervillain

Other games which are major influences include: 8bitMMO, Another World, Discworld 2, Clop, Osmos, Hacker Evolution: Untold, the sims 1, close combat 1, MTGO, Limbo, Doug TenNapel games, Lemmings, Freedom Force, Gain Ground, Gynoug, Joust, Robocop Vs The Terminator, Ecco: the Dolphin, Super Meat Boy and Syphon Filter 1.

Also does anyone have tips about marketing, or should I not worry until I have an early build?
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!