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

Username:   Password: 
 RegisterRegister   
 half a battle engine with ATB
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
omni




PostPosted: Sun Apr 18, 2004 12:17 pm   Post subject: half a battle engine with ATB

This is the beginning of a RPG battle engine with Active Time Battles.
code:

%Jeffery Liu

%-------- player 3s bar
%-------- player 2s bar
%-------- player 1s bar
var bar : array 1 .. 3 of int := init (1, 2, 3) %starting speed
var speed : array 1 .. 3 of int := init (2, 3, 1) %how fast you want to increment
var enemybar : array 1 .. 3 of int := init (3, 2, 1) %starting speed
var enemyspeed : array 1 .. 3 of int := init (1, 1, 2) %how fast enemy speed increments
var names : array 1 .. 3 of string := init ("Jeffery", "insert", "name") %insert names
var key : string (1)
locate (22, 7)
put "Enemys"
locate (22, 73)
put "Players"
loop
    %increasing enemy speed
    for count : 1 .. upper (enemyspeed)
        if enemybar (count) > 50 then %checking if the bar reached the end
            enemybar (count) := enemybar (count) - 50 %set speed to starting speed
            locate (1, 1)
            put "Enemy ", count, " turn"
            getch (key)
        else
            enemybar (count) := enemybar (count) + enemyspeed (count) %otherwise increase
        end if
    end for
    %drawing the bar
    for count : 1 .. upper (enemybar)
        drawfillbox (52, count * 10, 102, count * 10 + 10, brightgreen)
        drawfillbox (102 + enemybar (count) - 50, count * 10, 102, count * 10 + 10, black)
    end for
    delay (50)
    %increasing player speed
    for count : 1 .. upper (bar)
        if bar (count) > 50 then
            bar (count) := bar (count) - 50
            locate (1, 1)
            put names (count), "s turn"
            getch (key)
        else
            bar (count) := bar (count) + speed (count)
        end if
    end for
    %drawing the bars
    for count : 1 .. upper (bar)
        drawfillbox (maxx - 50, count * 10, maxx, count * 10 + 10, yellow)
        drawfillbox (maxx + bar (count) - 50, count * 10, maxx, count * 10 + 10, black)
    end for
end loop
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sun Apr 18, 2004 3:09 pm   Post subject: (No subject)

Interesting...not quite sure I understand exactly what is going on though.
Tony




PostPosted: Sun Apr 18, 2004 4:10 pm   Post subject: (No subject)

some RPGs employ such battle order where each character has his/her own timer for which they must wait before making another turn. This way certain characters can attack more often then others

not much of an engine so far though... too much is hardcoded Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
gamer




PostPosted: Sun Apr 18, 2004 4:33 pm   Post subject: (No subject)

oic....dats pretty good

btw omni, ar u plannin to incorporate this into ur bird-eye-view shooter game??
Delos




PostPosted: Sun Apr 18, 2004 5:04 pm   Post subject: (No subject)

Ah, Timers...so that's what they are supposed to be...they did vaguely remind me of FF7...which is odd since I'm playing it right now...well, not at this very moment...sadly...
guruguru




PostPosted: Sun Apr 18, 2004 7:22 pm   Post subject: (No subject)

omni (Jeffery Liu) are u Geoffrey Lui by any chance? Do you know, of many people, Ms. Gauthier?
omni




PostPosted: Mon Apr 19, 2004 11:33 am   Post subject: (No subject)

gamer: no, I don't see the point of putting that system in my shooting game
gururu: NO, I have no idea who geoffry lui is Just because I have the same last name as somebody who is also chinese, doesn't mean we are related.
tony: what do you mean by hardcoded? Do you mean that I use too many constant values instead of variables?
Delos




PostPosted: Mon Apr 19, 2004 11:56 am   Post subject: (No subject)

Hardcoded just means that you made it for that particular screen, with those particular colours, names, speeds, etc etc etc. Were it not so, you could package it up and dump it into any programme you so desired and it would work well without disrupting anything else.

So, basically, too many constants almost= hardcoded.

Think of it as a prog that finds multiples of 5. You could always hardcode it so that any number entered will be compared with its reference within the prog, then the answer displayed; or you could use a bunch of vars and formulae instead.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Apr 19, 2004 12:52 pm   Post subject: (No subject)

omni wrote:
Do you mean that I use too many constant values instead of variables?


not that... you can use as many constants as you like... but I mean it would be very hard for me to implement this engine into a game of my own because I'd have to change a lot of stuff around, replace constants with variables that are linked to my characters and write my own procedures to make this actually work Confused I'll just end up using like 1~2 lines of your code and perhaps some variable stucture at the end Rolling Eyes So much for an "engine"

First of all you need to package it into procedures. Even better - a module. And have something like initialize() where you pass on the variables or atleast their values that are to be used.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: