Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 classes help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
evildaddy911




PostPosted: Tue May 08, 2012 10:43 am   Post subject: classes help

What is it you are trying to achieve?
I'm trying to replicate the pokemon combat system, in the hopes that i can create a new game with it

What is the problem you are having?
when i use the initialize procedure of the character class, the player's data gets replaced by the enemy -> initialize parameters

Describe what you have tried to solve this problem
this is one of my first projects with classes, so i have no idea what is wrong

if anyone can help me clean up my code, it would be appreiciated too

Please specify what version of Turing you are using
open atm, the school has 4.0.5, my home has 4.1.1a



exp table.txt
 Description:
you need this for the leveling system to work

Download
 Filename:  exp table.txt
 Filesize:  724 Bytes
 Downloaded:  78 Time(s)


classes.t
 Description:
this is the code, at the moment, i have only created 1 attack

Download
 Filename:  classes.t
 Filesize:  7.14 KB
 Downloaded:  60 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Tue May 08, 2012 12:47 pm   Post subject: Re: classes help

evildaddy911 wrote:
when i use the initialize procedure of the character class, the player's data gets replaced by the enemy -> initialize parameters


I'm not sure what the expected behavior is. What is supposed to happen that is not happening, or what is happening that shouldn't?
evildaddy911




PostPosted: Tue May 08, 2012 2:54 pm   Post subject: Re: classes help

on lines 223 and 224 (ive made some changes, so the old file may have this on different lines), i have
Turing:
player -> initialize ("player", Rand.Int (50, 200), Rand.Int (50, 200), Rand.Int (500, 2000), player -> get_xp, player -> get_lv) %   sets up random player/enemy stats
enemy -> initialize ("enemy", Rand.Int (50, 200), Rand.Int (50, 200), Rand.Int (500, 2000), enemy -> get_xp, enemy -> get_lv)

[ proc initialize (name : string, attack, defence : real, health, Exp, Level : int) ]
what is happening, is the second initialize call is overriding the first, giving both enemy and player identical stats. I dont want this, i want the player and enemy to have different stats. I thought that when you defined variables for one object, they would not alter another object of the same class's variables. I have no idea why this is happening, so im asking how to fix it



classes.t
 Description:
updated file

Download
 Filename:  classes.t
 Filesize:  7.42 KB
 Downloaded:  62 Time(s)

Zren




PostPosted: Tue May 08, 2012 6:58 pm   Post subject: RE:classes help

Turing:

    function get_attk : real
        result temp.Atk
    end get_attk

    function get_def : real
        result temp.Atk
    end get_def
evildaddy911




PostPosted: Thu May 10, 2012 3:06 pm   Post subject: RE:classes help

thanks, fixed now
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: