This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-02-21 21:47:45

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Elf Lands

NOT PROMISING THAT THIS WILL KEEP UP!!! Well, I'm sorta rewriting this in python. If you would like to help, let me know. Even if you don't know python, you can still help! So far, I have the character creation just about finished. One thing I need help with, is I want the program to send me an email when a player signs up, that tells me the name of the player, as well as where they heard about the program. My one problem is sending python variables in the email. Could anyone explain to me how to do this?

Here is my code so far.

Code:

#Type run() to start


def run(): start()


def start():

    import time
    import random
    print ("Please choose a class. Your class will affect abilities your player will have, as well as your stats.")
    print ("1. Knight")
    print ("2. Mage")
    print ("3. Elf")
    answer = raw_input("Choose an option, and then press enter. ")
    if(answer == "1"): type = "knight"
    elif(answer == "2"): type = "mage"
    elif(answer == "3"): type = "elf"
    print
    print
    print ("You chose to be a {0}.".format(type))
    time.sleep(2)
    print
    print

    #stats
    hunger = 100
    health = 100
    str = 0
    dex = 0
    wis = 0
    str = random.randint(50,100)
    dex = random.randint(50,100)
    wis = random.randint(50,100)
    print ("Rolling Stats...")
    time.sleep(2)
    print
    print
    print ("Strength: {0}".format(str))
    print ("Dexterity: {0}".format(dex))
    print ("Wisdom: {0}".format(wis))
    print
    print ("Here are your stats. They are going to stick with you though out the game. These numbers will effect how your charater performs though out the game. ")
    time.sleep(2)
    
    #name
    print
    print
    name = raw_input("I almost forget to ask you. What is your name? ")
    print
    print
    print ("Thank you for playing {0}.".format(name))
    time.sleep(2)

    #hear about us
    print
    print
    print ("One last question. ")
    answer = raw_input("Where'd you hear about us? ")


    #start
    print
    print
    print (""" You find yourself standing in the woods, with a knight mounted on a horse. """)
    print (""" "So young {0}. You seem to be new to Elf Lands, so I will instruct you """.format(type))
    time.sleep(5)
    print (""" through the ways of playing Elf Lands." The knight says. "I'm going to""")
    print ("""the town square. Here you will be able to do a number of things, including""")
    time.sleep(5)
    print ("""quests, and shoping. To travel, choose an exit, and type the corresponding """)
    print ("""then press enter. You will then travel to that destination where your travels""")
    time.sleep(5)
    print ("""Will continue", he says. "Let's try it out now. I'll meet you in the west exit." """)
    print ("You stand at the woods behind Elf Square.")
    time.sleep(5)
    print ("You notice one exit.")
    print ("1. West")
    answer = raw_input("Choose a number, and then press enter. ")
    if answer == "1":
        location = ("elfSquare")


    if location == "elfSquare":
           print
           print
           print ("You walk west towrds Elf Square. There, you meet the knight. He greets you, ")
           print ("and shows you around the square.")
           print ("He shows you four exits.")
           print ("1. The Dark Woods")
           print ("2. The Training Tent")
           print ("3. The Town of Ishka")
           print ("4. Seans Armory")
           print("You're on your own now, young {0}. Enjoy the adventure! ".format(name))
           if answer == "1":
               location = ("darkWoods")
           if answer == "2":
               location = ("trainingTent")
           if answer == "3":
               location = ("Ishka")
           if answer == "4":
               location = ("seansArmory")

Last edited by elfin8er (2012-05-07 11:31:33)


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#2 2012-02-21 22:41:19

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

Am I looking at this the wrong way? Should I use something other PHP?


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#3 2012-02-21 23:01:32

samtwheels
Scratcher
Registered: 2011-03-20
Posts: 1000+

Re: Elf Lands

use python!

Offline

 

#4 2012-02-21 23:04:02

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

samtwheels wrote:

use python!

Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#5 2012-02-21 23:08:30

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: Elf Lands

Use session variables and/or mySQL.
Here's a tutorial: http://www.w3schools.com/php/php_sessions.asp
If you just need a temporary variable, use sessions.
Basically, you start a session using session_start();, and have session variables set using $_SESSION['health']=10;.
If you need the website to permanently record the user data though, you'll need to use mySQL.
Create a new database, and a new table inside it with the details of each user's account name, health, money etc.
Then query and update the table whenever the user interacts within your RPG.
You'll need to know a certain amount of mySQL though.
Here's a beginner's tutorial: http://www.w3schools.com/php/php_mysql_intro.asp


http://trinary.tk/images/signature_.php

Offline

 

#6 2012-02-21 23:10:08

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Elf Lands

Theoretically it should be easier to learn Python than PHP.

Offline

 

#7 2012-02-21 23:12:05

samtwheels
Scratcher
Registered: 2011-03-20
Posts: 1000+

Re: Elf Lands

elfin8er wrote:

samtwheels wrote:

use python!

Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.

oh, you meant online. python runs on servers, but it's primarily client-side.

Offline

 

#8 2012-02-21 23:18:59

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

samtwheels wrote:

elfin8er wrote:

samtwheels wrote:

use python!

Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.

oh, you meant online. python runs on servers, but it's primarily client-side.

So I should stick with PHP MySQL?


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#9 2012-02-21 23:21:04

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

Why does everyone who program have a really hard accent? I hope my collage professer isn't like that. This guy said computer like cumpootre


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#10 2012-02-21 23:34:15

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

Could someone kind of start me out here? I just need the coding for the registration, and login, and I may need a bit of info on how to use the variables for the user only.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#11 2012-02-21 23:38:12

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Elf Lands

elfin8er wrote:

samtwheels wrote:

elfin8er wrote:


Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.

oh, you meant online. python runs on servers, but it's primarily client-side.

So I should stick with PHP MySQL?

Depends. If you want it to be a browser game, then definitely, stick with it. Though if you want it to be an application/program, then I would go with Python.

If you want it multiplayer, real-time strategy, Python would be a better option. If you want it to be turn-based, then PHP.

All depends on how you want the game to run. Could you give us details on what type of RPG it will be?

Offline

 

#12 2012-02-21 23:52:05

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

I want it to sort of be a browser based game, sort of like a mix between dungeons and dragons, and Choose Your Own Adventures. Here's how I'd want to layout to look.




Money: 10.00           HP: 100/100                                                              Elfin8er



You are walking through the desert, and you see ten dollars on the ground. What would you like to do?

Pick it up
Ignore it






Now, depending on what the user picks, will depend on what happens in the game. If the user chooses to pick up the ten dollars, ten dollars will be added to the money, and the game may say something like:

You decided to pick up the ten dollars. Ten dollars has been added to your money. Now what?

Return Home
Go Swimming


Sometimes, the user will encounter enemies. It would say something like this.


You have encountered a wolf. What would you like to do?

Fight the Wolf
Run From the Wolf


Then, if the user decided to fight the wolf, the computer would decide if the user hit the wolf or not, and if so, how much HP the wolf would loose. The user would then be taken to another page saying something like:

You hit the wolf. You did 10 damage to the wolf. The wolf now has 20 HP.


and the whole thing would start over again. I think I can do that whole part. The part I'm not sure about is making a user Signup/Login page, and using the variables like that.

Last edited by elfin8er (2012-02-21 23:53:08)


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#13 2012-02-22 00:47:17

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Elf Lands

Yeah, that's definitely something you want to make in PHP.

With phpMyAdmin you can create a table (like game_users) then have columns like Username, Password (make sure it's hashed), HP, XP, Money, Kills, Strength, Defense, Agility, etc.

Then you make a MySQL query to create/update/delete a row/user. Trinary's link to W3Schools is probably a good place to learn and use as a reference.  smile

Offline

 

#14 2012-02-22 08:10:31

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

Magnie wrote:

Yeah, that's definitely something you want to make in PHP.

With phpMyAdmin you can create a table (like game_users) then have columns like Username, Password (make sure it's hashed), HP, XP, Money, Kills, Strength, Defense, Agility, etc.

Then you make a MySQL query to create/update/delete a row/user. Trinary's link to W3Schools is probably a good place to learn and use as a reference.  smile

Ok, cool, Thanks.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#15 2012-02-22 09:08:28

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Elf Lands

Hey um, just so you know, I learned C++ in under a week.

Offline

 

#16 2012-02-22 12:29:28

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

maxskywalker wrote:

Hey um, just so you know, I learned C++ in under a week.

Well, I'm not a very quick learner.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#17 2012-02-22 16:29:23

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

THIS IS FRYING MY BRAIN!! I've been working for hours on this, and just still can't figure it out. Could someone just collab with me for a bit, and do the PHP for/with me? I'm also getting dreamweaver, so that should make it a bit easier as well.

Last edited by elfin8er (2012-02-22 17:32:43)


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#18 2012-02-22 18:15:39

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

I'm getting some errors with my login script. Could anyone look it over for me?

Code:

<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)
{
    
        $connect = mysql_connect("mysql6.000webhost.com","a9315431_elf","password") or die ("Failed to connect");
        mysql_select_db("a9315431_elf") or die ("Failed to connect to database");
        $query = mysql_query("SELECT * FROM users WHERE username='$username'");
        
        
        $numrows = mysql_num_rows($query);
        
        if($numrows !=0)
        
        {    
        while ($rows = mysql_fetch_assoc($query));    
        {
        
            $dbusername = $row['username'];
            $dbusername = $row['password'];
        
        }
            if ($username==$dbusername&&$password==$dbpassword);
            {
                
                echo "Logged in. Click <href='http://elflands.tk/start.php'>Click Here to Start Your Adventure</a>";
                $_SESSION['username']=$dbusername;
                
            }
            
            else
                echo "Incorrect Password";
        
        }
        
        else
            die "That username doesn't exist.";
        
}
else
    die ("Please Enter A Username And Password");
    

?>

Am I even on the right track here?

Last edited by elfin8er (2012-02-22 18:33:49)


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#19 2012-02-22 18:29:04

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Elf Lands

You'll want to close all the else's with } and make sure to hash passwords.

Offline

 

#20 2012-02-22 18:34:02

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

Magnie wrote:

You'll want to close all the else's with } and make sure to hash passwords.

C.RAP! I forgot!!!!


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#21 2012-02-22 18:36:31

Earthboundjeff
Scratcher
Registered: 2010-09-28
Posts: 1000+

Re: Elf Lands

This is actually a genre, and a pretty famous one at that.
It's called, oddly enough, Text-Based Gaming
And the idea looks pretty awesome.

Last edited by Earthboundjeff (2012-02-22 18:37:34)


https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcR1SONrHUmdKZXQNDgtN_vpycOOo-BDMfnlqHZRA1lMpYXhX7Jc

Offline

 

#22 2012-02-22 18:36:52

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

...and I can't figure out where I'm missing the { and }'s


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#23 2012-02-22 18:37:53

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

Earthboundjeff wrote:

This is actually a genre, and a pretty famous one at that.
It's called, oddly enough, [spoiler=Text-Based Gaming]http://en.wikipedia.org/wiki/Text-based_game[/spoiler]
And the idea looks pretty awesome.

I know, but I didn't want people to get confused with choose your own adventures.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#24 2012-02-22 18:38:39

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Elf Lands

maxskywalker wrote:

Hey um, just so you know, I learned C++ in under a week.

Liar!

D: I am jealous, took me 2  sad


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#25 2012-02-22 20:54:53

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Elf Lands

elfin8er wrote:

...and I can't figure out where I'm missing the { and }'s


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

Board footer