Computer Science Canada

Final Fantasy III battle game help

Author:  Az [ Fri Dec 23, 2005 6:51 pm ]
Post subject:  Final Fantasy III battle game help

I am working.. or atleast starting to work on a game that i would hope turns out something like the battle's in the game "Final Fantasy III" made by Square-Enix. I have to pick a game to make for my comp sci class and I chose to do something like that.

Anyway, the point of all this is that I need help, I'm basically new to Turing besides the class i have been taking since the beginning of school this september. I would like to know if anyone could give tips on like which parts of the game should be in arrays or record file stuff.

--- here is the jist of the game
1) have a start menu with login / password type thing
2) begin battle, have basic background and just some GUI stuff like that
3) when battle starts, player 1 (you) has a "battle menu" with choices such as Attack, Items, Magic etc.
4) monster (CPU) cannot go when it is player 1's turn and vice-versa
5) player 1 and monster with have Health points (HP) and Magic points (MP)
6) when it is monsters turn, it will randomly generate a number which will represent which choice it makes from it's menu
7) damage done by attacks will be random numbers between a certain range
8)if player 1 loses all HP (counter reaches 0 or something) then some sort of You lose screen will come up and restart the program
9) if player 1 wins, well... player 1 wins and game ends Smile

and i think that would be about it... any help would really be nice.
thanks Very Happy

Martin says:I changed the title. Please don't make 'I need help topics'

Author:  Cervantes [ Fri Dec 23, 2005 7:53 pm ]
Post subject: 

Knowing about classes would help you a lot here. Check the Turing Walkthrough for a link to the tutorial on this topic.

This sounds pretty complex. Be sure to work everything out on paper before you begin coding.

Author:  MysticVegeta [ Sat Dec 24, 2005 11:57 am ]
Post subject:  Re: Working on a game... need some help

Az wrote:

6) when it is monsters turn, it will randomly generate a number which will represent which choice it makes from it's menu


Hmm I would suggest you make that a Little AI because it would be foolish for the CPU to cast a magic when player 1 has just 1 hp left and some other things could be done too to increase the interactivity and this could be done using simple if structures, no algorithms required Smile

Author:  Az [ Sat Dec 24, 2005 10:16 pm ]
Post subject:  AI

any tips on making an AI... the whole random number thing was my first thought on it... I really have no idea how AI works, if anyone could explain it to me that would help alot with the monster. thanks Smile

Author:  chrispminis [ Sat Dec 24, 2005 11:03 pm ]
Post subject: 

You could use if statements such as, if other char just charged up, then defend or something. I dunno the context of the game. You don't have to use anything complicated, just think logically. How could the AI counter you. But don't make it impossible. ex. if AI follows the other example it renders charging up obselete.

Author:  Martin [ Sun Dec 25, 2005 2:42 am ]
Post subject: 

For AI in something like that, you want it to be somewhat random (so the player doesn't figure it out) and you want it to be intelligent.

For the most basic, let's say the monster has two abilities - attack and heal.

What you'd do is generate a probability table of its action for certain cases.

In the above, let's say we have three cases

1. Monster health full:
Attack:100%
Heal:0%

2. Monster health not full but greater than 40%
Attack: 75%
Heal: 25%

3. Monster health less than or equal to 40%
Attack: 25%
Heal:75%

And so on. You could divide this as much as you want.

Author:  MysticVegeta [ Sun Dec 25, 2005 12:19 pm ]
Post subject: 

And for example: organizing attacks...
If CPU has 60 MP

Magic uses : 50
Small Attack : 10
Large Attack : 30

So the best possible you know is Magic + Small attack because if you use Large attack you would have to choose Small attack later and be left with 20 MP to do just 2 more small attacks causing minimal damage...

Author:  Az [ Sun Jan 01, 2006 4:01 pm ]
Post subject:  lets get started

ok well now that I know that I will need that kinda stuff. I'm still not the greatest so hopefully someone could guide me through it step by step Very Happy

first off. I'm guess I will need to write the program for the login screen.
I am not 100% sure how I would display something like that, Draw.Window or something like that? I remember my teacher saying something about how I would get the basic window up but I forgot what the code is Mad. anyway If anyone could help me with the code for making a basic login screen, that would be great... just a window with something like...
___________________________________________
|_________FF Battle_________________________x|
| |
| Account Name: (account name entered here) |
| |
| Password: (password entered here) |
|__________________________________________|

just something that would end up like that.. lol sorry about the bad .. drawing? but it gets to the point.. it doesnt have to be anything special,
I am in a beginners class anyway. so basically I just need to know the code for how to get a window up like that and have the account name stored in an array for the next time they log on they can just select their account name from a list or something.

any help would be great! Very Happy thanks

Author:  MysticVegeta [ Sun Jan 01, 2006 4:35 pm ]
Post subject: 

Hmm, if you need yours to look like professional, how about making the graphic using photoshop/illlustrator or paint even... followed by a simple if structure for the login.

Also, to open it up in a new window, you need to check

Window.Open (parameters) commands in Turing manual, (F10)

There are lots of Window."x" commands where x could be Set, SetActive, GetActive, lots of commands. You will find the complete explanation in the Turing manual though.

Author:  Albrecd [ Sun Jan 01, 2006 4:35 pm ]
Post subject: 

To open another window:

code:
var winID : int
winID := Window.Open ("position:top;center,graphics:200;200")


You can change the position and characteristics. Almost any characteristic that can be used in a normal window can be used in the new window. Ex: offscreenonly, nobuttonbar, nocursor, etc.

Author:  do_pete [ Sun Jan 01, 2006 5:03 pm ]
Post subject: 

You may also want to use Turing's GUI or you could make your own

Author:  Az [ Sun Jan 01, 2006 9:18 pm ]
Post subject:  GUI question

how does the GUI work? my class has gone over it just once, and not for long. so it wasnt very helpful. Razz the teacher didnt really do a whole lesson on it, just a quick peek. so im just wondering which GUI does what and how any of them may help or if i should just make my own

Author:  Az [ Sun Jan 01, 2006 9:58 pm ]
Post subject: 

to start off...

code:
%delcare account name array
var arrAcntName : array 1 .. 20 of int
%initialize array
var i : int
const LB : lower (arrAcntName)
const UB : upper (arrAcntName)
for i
    i := LB..UB arrAcntName (i)
end for


trying to declare the account name array, but i keep forgetting how to do the const and declaring the counter for search of the array later on (i was taught to use a for loop and set the int as something but hell i cant remember Crying or Very sad


and then...


i get the window open and i have the account name and password put and get statements... first of all, how do i get the account name that is entered, to become part of my account name array (so that later on the user can choose their acount from a list)


and 2nd. it is obvious that a password is private most games or programs use the "*" or something like that to be displayed when the user types in their password so that its a secret
if that was a pretty bad attempt at explaining of the password entering program. i'm pretty sure most people will understand what i am talking about . just wondering how you can do that with turing. i have no idea what the code would be. help me please

Author:  do_pete [ Sun Jan 01, 2006 10:43 pm ]
Post subject: 

You have to use ":=" instead of ":". for loops work like this:
code:
for i : lowerNumber .. higherNumber

Author:  Cervantes [ Mon Jan 02, 2006 9:32 am ]
Post subject: 

Az wrote:

i get the window open and i have the account name and password put and get statements... first of all, how do i get the account name that is entered, to become part of my account name array (so that later on the user can choose their acount from a list)


and 2nd. it is obvious that a password is private most games or programs use the "*" or something like that to be displayed when the user types in their password so that its a secret
if that was a pretty bad attempt at explaining of the password entering program. i'm pretty sure most people will understand what i am talking about . just wondering how you can do that with turing. i have no idea what the code would be. help me please

1. You'll need to use a Flexible Array.
2. You'll need to use getch. Inside a loop, you getch each character, add it to your growing string, and draw another "*". Exit the loop if the enter key is pressed (if you getched chr (10) or something like that.)

Author:  do_pete [ Mon Jan 02, 2006 12:02 pm ]
Post subject: 

What's the difference between getch and getchar?

Author:  DIIST [ Mon Jan 02, 2006 1:46 pm ]
Post subject: 

do_pete wrote:
What's the difference between getch and getchar?


Getch is a procedure which waits until a specific character is pressed. Getchar is function that returns the character that is pressed.

Author:  do_pete [ Mon Jan 02, 2006 2:11 pm ]
Post subject: 

Thanks, I understand now

Author:  Az [ Mon Jan 02, 2006 2:27 pm ]
Post subject:  question about getch

code:

loop
    put ""
    put "        " ..
    %get user account name
    put "Account Name: " ..
    get acntName
    if acntName = "q" or acntName = "Q" then
        exit
    end if
    put ""
    put "            " ..
    %get user password
    put "Password: " ..
    get password
    put ""
    put ""
    exit
end loop


ok that is my code so far for login.. but I dont understand where I would put the getch for the * for the password. i'm not really sure how I code the loop in there

Author:  do_pete [ Mon Jan 02, 2006 3:13 pm ]
Post subject: 

You need 2 seperate loops; one for the password and one for the account. You'll also need to place the put "Password: " .. and put "Account Name: " .. outside of the loops. The getch and put "*" .. goes inside each loop

Author:  Az [ Mon Jan 02, 2006 7:39 pm ]
Post subject:  password problem

code:
put "Password: " ..
loop
    %get user password
    var ctr : int := 0
    var ch : string (1)
    ctr += 1
    exit when ctr = 10
    getch (ch)
    put "*"..
end loop


ok thats what i have for the password... but it still isnt working properly.
whenit asks for a password, the stuff you type in shows up as * but for keys like backspace, it just adds a * insted of backspacing, and the enter key add a * aswell insted of exiting the loop when pressed.

(also i would like to know how to get the ESC key to exit the whole program when the account is being entered or the password)

Author:  Cervantes [ Mon Jan 02, 2006 8:12 pm ]
Post subject: 

Az wrote:

whenit asks for a password, the stuff you type in shows up as * but for keys like backspace, it just adds a * insted of backspacing, and the enter key add a * aswell insted of exiting the loop when pressed.

Cervantes wrote:

Exit the loop if the enter key is pressed (if you getched chr (10) or something like that.)

code:

exit when input_char = chr (10)

code:

var str := ""
var ch : string (1)
loop
    ch := getchar
    exit when ch = KEY_ENTER
    if ch = KEY_BACKSPACE & length (str) > 0 then
        str := str (1 .. * -1)
    elsif index ("abcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM.,;:'\"?()&%$#@!", ch) not= 0 then
        str += ch
    end if
    locate (1, 1)
    put str
end loop

Author:  Az [ Mon Jan 02, 2006 10:18 pm ]
Post subject:  password

ok this is really bugging me

code:
put "Password: " ..
%get user password
loop
     getch (ch)
     exit when ch = KEY_ENTER %exit when enter key is pressed
     if ch = KEY_BACKSPACE and length (password) > 0 then
        password := password (1 .. * -1)
     elsif index("abcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM.,;:'\"?()&%$#@!", ch) not= 0 then
        password += ch
        put "*"
     end if
end loop


that code is for the password in my login, it all works EXCEPT that when I type in the password and press backspace, the password changes but the "*" still remains on the screen.

for example: let's say the password is "hello". when i type in the password "*****" (5) is displayed on the screen but if i press backspace, the password string changes to "hell" but the "*****" (5) is still on the screen rather than "****" (4). so the password changes but the "*" does not.

how do i fix this?

Author:  chrispminis [ Tue Jan 03, 2006 12:39 am ]
Post subject: 

Not too hard, in your if ch = KEY_BACKSPACE just add afterwards a
put "\B" .. This backspaces and is one of the formatting tools often forgotten Razz Well here's the changes in your code. GL with the rest of the program.


code:

%get user password
loop
     getch (ch)
     exit when ch = KEY_ENTER %exit when enter key is pressed
     if ch = KEY_BACKSPACE and length (password) > 0 then
        password := password (1 .. * -1)
        put "\B" ..
     elsif index("abcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM.,;:'\"?()&%$#@!", ch) not= 0 then
        password += ch
        put "*" ..
     end if
end loop

Author:  Az [ Tue Jan 03, 2006 12:54 am ]
Post subject: 

chrispminis wrote:
Not too hard, in your if ch = KEY_BACKSPACE just add afterwards a
put "\B" .. This backspaces and is one of the formatting tools often forgotten Razz Well here's the changes in your code. GL with the rest of the program.


thanks! Very Happy i was stuggling with that for awhile Shocked .

anyway, I seemm to be done the login programming. but currently its just a dull white screen with boring text. How would i change the text size/colour/font and also make the background a different colour?.. I am trying to figure that out now but alittle lost so i thought i would post this. Very Happy any help would be great, thanks

Author:  chrispminis [ Tue Jan 03, 2006 2:08 am ]
Post subject: 

Quote:
but currently its just a dull white screen with boring text. How would i change the text size/colour/font and also make the background a different colour?..


First of all, to change background colour use colourback.
The format is colourback (colourofchoice). Also works with American "color".
ex.
code:

colourback (12)
cls

outputs a red background.

Then to change the colour of normal size text use colour (or color).
colour (colourofchoice)
ex.
code:

colour (2)
put "This outputs text in Green"


But I think you want the Font commands. This is easy enough to understand. You can get the idea from this source code found in the Turing Help Files, on Font.Draw

code:

var font1, font2, font3, font4 : int
        font1 := Font.New ("serif:12")
        assert font1 > 0
        font2 := Font.New ("sans serif:18:bold")
        assert font2 > 0
        font3 := Font.New ("mono:9")
        assert font3 > 0
        font4 := Font.New ("Palatino:24:bold,italic")
        assert font4 > 0
        Font.Draw ("This is in a serif font", 50, 30, font1, red)
        Font.Draw ("This is in a sans serif font", 50, 80, font2, brightblue)
        Font.Draw ("This is in a mono font", 50, 130, font3, colorfg)
        Font.Draw ("This is in Palatino (if available)", 50, 180, font4, green)
        Font.Free (font1)
        Font.Free (font2)
        Font.Free (font3)
        Font.Free (font4)


For more detailed information read the Turing Help File on Font.Draw.

Don't forget the locate command if you haven't already learned about them. It locates normal text to a certain row and column. Read about that in the Turing Help File as well. In fact, you can find most of what you need to know in the Turing Help Files, and if it isn't there then check the Tutorials here at compsci.

Also for more professional looking programs, look into buttons.

Author:  Cervantes [ Tue Jan 03, 2006 8:58 am ]
Post subject:  Re: password

Az wrote:

for example: let's say the password is "hello". when i type in the password "*****" (5) is displayed on the screen but if i press backspace, the password string changes to "hell" but the "*****" (5) is still on the screen rather than "****" (4). so the password changes but the "*" does not.

how do i fix this?

You've got one solution, but let's examine an alternative, just because knowledge is good. Smile

code:

var str := "hello"

put repeat ("*", length (str))

Author:  Albrecd [ Tue Jan 03, 2006 9:13 am ]
Post subject: 

Quote:
First of all, to change background colour use colourback.


colourback will not work if you are using graphics too, in that case you just Draw.FillBox (0, 0, maxx, maxy, whatevercolour)

Author:  do_pete [ Tue Jan 03, 2006 12:35 pm ]
Post subject: 

What are you talking about colourback works

Author:  Az [ Tue Jan 03, 2006 1:24 pm ]
Post subject:  starting the game

ok I seem to be done the login of the game, so next I guess I would like to start the battle. So with that in mind, I want to open a new window and imput some GUI or something? lol not really sure what I do but i want it to look something like this...

Posted Image, might have been reduced in size. Click Image to view fullscreen.

if you dont know, that is a battle in final fantasy, and i would like my game to turn out with the same concept. I am not sure how i would draw the background, the menu or any of that Crying or Very sad I have some sort of idea but i would probably struggle for days trying to figure it out Confused I'm thinking for the boxes... just do a Draw.Box or Draw.FillBox, but the background and putting the characters/enemies in, not so sure about that.

Author:  Az [ Tue Jan 03, 2006 1:26 pm ]
Post subject:  also!

forgot to add to the previous post that I still need to do the enemies AI and player control. so if i need to do that first before making the graphics, let me know Smile and i will need help on the AI definatly Embarassed not so much on player controls, but we shall see Cool

Author:  [Gandalf] [ Tue Jan 03, 2006 8:45 pm ]
Post subject: 

Wow, Cervantes, I'd never used the repeat function before. Thanks for that little bit of knowledge. Smile

Az, if you wish your game to be measurably successful, I suggest you look at the Turing Walkthrough and read most of the tutorials there through carefully. To draw pictures on the screen you need to use the Pic module, and there will be countless other things which will come up that we already have tutorials on.

Also, Albrecd, colourback() and cls() work in any situation. You should never have to revert to the method you posted, so I'm not sure why you are...

Author:  Cervantes [ Tue Jan 03, 2006 9:23 pm ]
Post subject:  Re: starting the game

Az wrote:

if you dont know, that is a battle in final fantasy, and i would like my game to turn out with the same concept. I am not sure how i would draw the background, the menu or any of that Crying or Very sad I have some sort of idea but i would probably struggle for days trying to figure it out Confused I'm thinking for the boxes... just do a Draw.Box or Draw.FillBox, but the background and putting the characters/enemies in, not so sure about that.


Az, there are a million gajillion ways to do this. Some are easier than others. Some are structured, while others will lead you into a twilight-lit, twirling twister of... troglodytes. What I mean to say is that if you don't have the proper knowledge of aggregate data structures, you'll fall into this twister of untidiness, where each new feature increases the amount of code you have exponentially.

[Gandalf] wrote:
Wow, Cervantes, I'd never used the repeat function before. Thanks for that little bit of knowledge. Smile

You're most welcome! *Snicker*

Author:  Az [ Wed Jan 04, 2006 1:19 pm ]
Post subject:  ok problem

ok i have coded abunch of the game so far but there is 1 problem...

code:
proc P1battleMenu
    Draw.FillBox (200, 10, maxx div 2 - 105, maxy div 3 - 10, 1)
    Draw.Box (200, 10, maxx div 2 - 105, maxy div 3 - 10, 0)
    Font.Draw ("Attack (A)", 210, 190, fontBattle, white)
    Font.Draw ("Magic (M)", 210, 150, fontBattle, white)
    Font.Draw ("Heal (H)", 210, 110, fontBattle, white)
    var UserInput : string (1)
    getch (UserInput)
    if UserInput = "A" or UserInput = "a" then
        put P1attack %go to proc P1attack
    elsif UserInput = "M" or UserInput = "m" then
        put P1magic %go to proc P1magic
    elsif UserInput = "H" or UserInput = "h" then
        put P1heal %go to P1heal
    end if
end P1battleMenu


ok that displays the battle menu for P1, but the problem is when the user presses A , M or H. the top of the screen gets 1 black line, and it repeats every time it is player 1's turn and eventually makes the whole screen black. how can i fix this?

Author:  chrispminis [ Wed Jan 04, 2006 4:12 pm ]
Post subject: 

I'm not exactly sure what you mean by that, but I think using locate will solve it. Locate your text so that it doesn't appear at the top.

Author:  Az [ Thu Jan 05, 2006 1:05 am ]
Post subject:  almost done!

ok yea so i have been programming all day for the past 2 days basically Shocked but my game is almost done Very Happy all i need to know now is how to make a launcher for the game, insted of opening turning and running it everytime.

Author:  Cervantes [ Thu Jan 05, 2006 9:23 am ]
Post subject: 

Are you asking how to make a .exe?

Author:  Az [ Thu Jan 05, 2006 10:58 pm ]
Post subject:  almost done

ok i just need 1 more thing for my game. I just need to know if there is a command or code for exiting the program right away. because when the CPU or player 1 hp is less than 0, insted of stopping the fight and displaying, you win/lose etc. it keeps going

Author:  pavol [ Mon Jan 09, 2006 8:22 pm ]
Post subject: 

post your code or describe in more detail Smile

Author:  Avarita [ Tue Jan 10, 2006 4:29 pm ]
Post subject: 

If your battle's are animated, can u post how you did it? I am also making an rpg and I want an efficient way to do the animations.

Author:  Martin [ Tue Jan 10, 2006 7:27 pm ]
Post subject: 

To make it close, you have to do a few things.

First, use Window.Open to open a window and run your game in that. Then Window.Hide (defWinId) to hide the main run window. When the game ends, Window.Close (newWindow). Unfortunately, this will leave turing.exe running in the background as far as I know.

Author:  [Gandalf] [ Tue Jan 10, 2006 8:07 pm ]
Post subject: 

Nah, you can just exit the main loop and in the compiler options check "immediately close run window." This is not an option for simply running the source code, but if you're still doing that then exiting by yourself shouldn't be a problem.


: