2017-08-28 10 views
1

南に欲しい人のタイプの欲望の場所にタトゥーの特定の場所を移動させる方法を見つけることができません。setxとsetyの線それはそれをコードに送るでしょう私はコードをマップしました x開始エリア175各sqaureは50離れています| Yの開始領域380は、各sqaureが50離れている。私は私が学校で私のミニマップを作る方法を理解できません

from tkinter import * 
import tkinter.messagebox as tm 
####################LOUIS'S STORY################### 
class Theif_Story(): 

def Map_Starting_Area(): 
    import turtle 
    # X axis = 1 -> 5 
    # Y axis = A -> E 
    ########Compass####### 
    turtle.speed(99) 
    turtle.pu() 
    turtle.rt(90) 
    turtle.fd(150) 
    turtle.pd() 
    turtle.fd(75) 
    turtle.backward(150) 
    turtle.fd(75) 
    turtle.left(90) 
    turtle.fd(75) 
    turtle.backward(150) 
    turtle.pu() 
    turtle.backward(10) 
    turtle.write('W') 
    turtle.fd(10) 
    turtle.pd() 
    turtle.fd(150) 
    turtle.pu() 
    turtle.fd(10) 
    turtle.pd() 
    turtle.write('E') 
    turtle.pu() 
    turtle.backward(10) 
    turtle.backward(75) 
    turtle.rt(90) 
    turtle.fd(75) 
    turtle.pu() 
    turtle.fd(20) 
    turtle.pd() 
    turtle.write('S') 
    turtle.pu() 
    turtle.backward(10) 
    turtle.backward(170) 
    turtle.pd() 
    turtle.write('N') 
    turtle.pu() 
    turtle.backward(225) 
    turtle.pd() 
    #################### 
    #######Grid########### 
    turtle.left(90) 
    turtle.ht() 
    turtle.left(90) 
    turtle.forward(250) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(50) 
    turtle.right(90) 
    turtle.forward(250) 

    turtle.right(90) 
    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 

    turtle.left(90) 
    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 

    turtle.left(90) 
    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 

    turtle.left(90) 
    turtle.forward(50) 
    turtle.right(90) 

    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 
    turtle.left(90) 

    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 
    turtle.left(90) 

    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 
    turtle.left(90) 

    turtle.forward(50) 
    turtle.right(90) 
    turtle.forward(250) 
    turtle.backward(250) 
    turtle.left(90) 
    turtle.st() 
    ############ 
    # Square = Town 
    # Circle = Fight 
    # Arrow = Quest Marker 
    # Turtle = Weapon Shops 
    # Triangle = Potion Shop 
    # hollow circle = chest 
    turtle.backward(175) 
    turtle.right(90) 
    turtle.pu() 
    turtle.forward(75) 
    turtle.shape("square") 
    turtle.stamp() 
    turtle.shape("classic") 
    turtle.forward(150) 
    turtle.left(90) 
    turtle.fd(150) 
    turtle.shape("square") 
    turtle.stamp() 
    turtle.right(90) 
    turtle.shape("arrow") 
    turtle.color("blue") 
    turtle.stamp() 
    turtle.left(90) 
    turtle.color("black") 
    turtle.shape("classic") 
    turtle.lt(90) 
    turtle.fd(100) 
    turtle.shape("circle") 
    turtle.stamp() 
    turtle.shape("classic") 
    turtle.left(90) 
    turtle.forward(100) 
    turtle.shape("circle") 
    turtle.stamp() 
    turtle.shape("classic") 
    turtle.rt(90) 
    turtle.fd(100) 
    turtle.rt(90) 
    turtle.fd(50) 
    turtle.shape("circle") 
    turtle.stamp() 
    turtle.shape("classic") 
    turtle.rt(90) 
    turtle.fd(200) 
    turtle.right(90) 
    turtle.fd(100) 
    turtle.rt(90) 
    turtle.fd(10) 
    turtle.pd() 
    turtle.left(90) 
    turtle.circle(10) 
    turtle.rt(90) 
    turtle.pu() 
    turtle.fd(140) 
    turtle.color('blue') 
    turtle.rt(90) 

import random 
import time 
import turtle 

Wooden_Chest_Item_List = 'Wooden Short Blade', 'Wooden Axe', 'Wooden Stick', 'Wooden Long Blade', 'Stone Short Blade', 'Stone Axe', 'Stone Wand', 'Stone Long Blade', 'Iron Short Blade', 'Iron Axe', 'Iron Wand', 'Iron Long Blade', 'Diamond Short Blade', 'Diamond Axe', 'Diamond Wand', 'Diamond Long Blade' 
Weapon_Chest = random.choice(Wooden_Chest_Item_List) 

Potion_Use_Per_Battle = 3 
Life = 100 
Foe = random.randint(25, 150) 
Player_Dmg = 25 
Magic_Dmg = 10 
Foe_Dmg = 15 
Fists = Player_Dmg 
Weapon = Fists 

Wooden_Short_Blade = Player_Dmg + 3 
Wooden_Stick = Magic_Dmg + 5 
Wooden_Axe = Player_Dmg + 4 
Wooden_Long_Blade = Player_Dmg + 5 

Stone_Short_Blade = Player_Dmg + 5 
Stone_Axe = Player_Dmg + 6 
Stone_Wand = Magic_Dmg + 7 
Stone_Long_Blade = Player_Dmg + 7 

Iron_Short_Blade = Player_Dmg + 7 
Iron_Axe = Player_Dmg + 8 
Iron_Wand = Magic_Dmg + 9 
Iron_Long_Blade = Player_Dmg + 9 

Diamond_Short_Blade = Player_Dmg + 9 
Diamond_Axe = Player_Dmg + 10 
Diamond_Wand = Magic_Dmg + 11 
Diamond_Long_Blade = Player_Dmg + 11 
Bupe_Doop = Player_Dmg + Magic_Dmg + 5 ##Louis's Custom Weopon 

Small_Health_Potion_Amount = random.randint(0,3) 
Medium_Health_Potion_Amount = random.randint(0,3) 
Large_Health_Potion_Amount = random.randint(0,3) 


print('You Continue with your Journey') 
print('You leave the protection of your farm and head into the open land') 
print(Map_Starting_Area()) 
print('You Come to a cross road') 
print('Would you like to go South, West or East ') 
Direction = str(input()) 
if Direction == 'South': 
    turtle.sety(330) 
    turtle.update() 
elif Direction == 'East': 
    turtle.setx(225) 
    turtle.update() 
elif Direction == 'West': 
    turtle.setx(125) 
    turtle.update() 
print('Which way do you go') 
Direction2 = str(input()) 
if Direction2 == 'South': 
    turtle.sety(330) #Stuck on this part since theirs 3 diffrent solution 
    turtle.update() 
elif Direction2 == 'East': 
    turtle.setx(225) 
    turtle.update 
elif Direction2 == 'West': 
    turtle.setx(125) 
    turtle.update() 
    print('You encounter a raverous Spider! do you wish to fight it?') 
    Fight = str(input()) 
    if Fight == 'Yes': 
     #########Battle Code Warrior############ 
     import random 
     import time 


     While_Loop = 1 
     ###########Battle 1############ 
     print("""Spider Appers, You Need to do 10 dmg to kill this enemy!!!""") 
     print('============================================') 
     while While_Loop == 1: 
       if Foe >= 0: 
        time.sleep(1) 
        print('You did', Player_Dmg,'Dmg') 
        Foe = Foe - Player_Dmg 
        print('Your Foe has ',Foe,'Hp left') 
        print('=============================') 
        time.sleep(0.5) 
        Player_Dmg = random.randrange(0,10) 
        if Foe <= 0: 
         print('You killed it') 
         break 

        else: 
         time.sleep(1) 
         if life >= 0: 
          life = life - Foe_Dmg 
          print('You took ', Foe_Dmg,'Dmg') 
          print('You Have', life, 'Hp left') 
          print('=============================') 
          time.sleep(0.5) 
          Foe_Dmg = random.randrange(0, 10) 
          if life <= 0: 
           print('You are dead') 

       else: 
        print('You die') 
        life = 0 
        break 

    elif Fight == 'No': 
     print('You Sprint Frantically away from the spider while it chases you down!') 
     turtle.backward(100) 
elif Direction2 == 'South': 
    turtle.fd(50) 

答えて

1

をそれを提示したいので、私はあなたが5×5のグリッドの周りに亀(青丸)を移動することができます例を作成するには、以下のコードのちょうど十分抽出してきたpygameのを使用していませんコンソールでコマンド北、南、東&西を使用して:

import turtle 

GRID_UNIT = 50 
GRID_SIZE = 5 # code below assumes this is an odd number 

def Map_Starting_Area(): 

    turtle.pu() 
    turtle.goto(-GRID_SIZE/2 * GRID_UNIT, -GRID_SIZE/2 * GRID_UNIT) 
    turtle.ht() 
    turtle.pd() 

    ####### Grid ########### 

    for _ in range(GRID_SIZE // 2): 
     turtle.forward(GRID_SIZE * GRID_UNIT) 
     turtle.left(90) 
     turtle.forward(GRID_UNIT) 
     turtle.left(90) 
     turtle.forward(GRID_SIZE * GRID_UNIT) 
     turtle.right(90) 
     turtle.forward(GRID_UNIT) 
     turtle.right(90) 

    turtle.forward(GRID_SIZE * GRID_UNIT) 
    turtle.left(90) 
    turtle.forward(GRID_UNIT) 
    turtle.left(90) 
    turtle.forward(GRID_SIZE * GRID_UNIT) 
    turtle.left(90) 

    for _ in range(GRID_SIZE // 2): 
     turtle.forward(GRID_SIZE * GRID_UNIT) 
     turtle.left(90) 
     turtle.forward(GRID_UNIT) 
     turtle.left(90) 
     turtle.forward(GRID_SIZE * GRID_UNIT) 
     turtle.right(90) 
     turtle.forward(GRID_UNIT) 
     turtle.right(90) 

    turtle.forward(GRID_SIZE * GRID_UNIT) 
    turtle.left(90) 
    turtle.forward(GRID_UNIT) 
    turtle.left(90) 
    turtle.forward(GRID_SIZE * GRID_UNIT) 
    turtle.pu() 
    turtle.home() 

    turtle.st() 

turtle.speed('fastest') 

Map_Starting_Area() 

turtle.color('blue') 
turtle.shape('circle') 

print('You Continue with your Journey') 
print('You leave the protection of your farm and head into the open land') 
print('You Come to a cross road') 

while True: 
    direction = input('Would you like to go North, South, East or West: ').lower() 

    if direction == 'north' and turtle.ycor() < GRID_UNIT * (GRID_SIZE//2 - 0.5): 
     turtle.sety(turtle.ycor() + GRID_UNIT) 
    elif direction == 'south' and turtle.ycor() > -GRID_UNIT * (GRID_SIZE//2 - 0.5): 
     turtle.sety(turtle.ycor() - GRID_UNIT) 
    elif direction == 'east' and turtle.xcor() < GRID_UNIT * (GRID_SIZE//2 - 0.5): 
     turtle.setx(turtle.xcor() + GRID_UNIT) 
    elif direction == 'west' and turtle.xcor() > -GRID_UNIT * (GRID_SIZE//2 - 0.5): 
     turtle.setx(turtle.xcor() - GRID_UNIT) 

    elif direction == 'quit': 
     break 

コードは、グリッドを離れるからあなたのカメを防ぐことができます。ロジックを単純化するために、グリッドを(0、0)の中央に配置しました。これをあなたのプログラムに組み込んで、カメの動きを制御してくれることを望みます。

通常、私は実際にはイベントベースのカメプログラムでwhile True:を避けたいと思いますが、今のところ最も単純な解決策です。

+0

ありがとうございます!これは役に立ちます –

関連する問題