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

Username:   Password: 
 RegisterRegister   
 Real Time Strategy
Index -> Programming, Java -> Java Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DanShadow




PostPosted: Thu Apr 20, 2006 1:31 am   Post subject: Real Time Strategy

This is a Real Time Strategy (RTS) game I was developing while doing an upgrade compsci course in High School.
It plays generally like most RTS' (like Age of Empires), except for a glitch I never seemed to get working... the AI. I have a fair amount of programmed AI.. but for some unknown reason all it will do is make an enemy unit run when its attacked.. and attack you back as its running for its life =).
I have stopped working on this game, so please dont tell me to add to it, heh.
Later on, I will be working on an RPG which later I will form into an MORPG when I get the bugs kicked out of my Java NET programs, heh.

Anyway, I suggest reading the 'ReadMe' File (.html format) in the 'ReadMe' folder before playing, it will explain the game a bit better.

To play the game, open 'Java RTS.html'.



JavaRTS.zip
 Description:
Java RTS

Download
 Filename:  JavaRTS.zip
 Filesize:  674.4 KB
 Downloaded:  540 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Apr 20, 2006 11:31 am   Post subject: (No subject)

code:
        public void createUnit(int UnitType) {
                if (UnitType==SETTLER) {
                        unitType=UnitType;
                        maxhp=30;
                        hp=maxhp;
                        coinCost=0;
                        foodCost=40;
                        att=1;
                        ac=0;
                        selected=false;
                        speed=4;
                        buildRate=15;
                } else if (UnitType==SCHOLAR) {
                        unitType=UnitType;
                        maxhp=25;
                        hp=maxhp;
                        coinCost=150;
                        foodCost=60;
                        att=1;
                        ac=0;
                        selected=false;
                        speed=2;
                } else if (UnitType==ENGINEER) {
                        unitType=UnitType;
                        maxhp=40;
                        hp=maxhp;
                        coinCost=120;
                        foodCost=70;
                        att=2;
                        ac=0;
                        selected=false;
                        speed=5;
                        buildRate=40;
                } else if (UnitType==WARMINISTER) {
                        unitType=UnitType;
                        maxhp=45;
                        hp=maxhp;
                        coinCost=200;
                        foodCost=50;
                        att=3;
                        ac=4;
                        selected=false;
                        speed=3;
                } else if (UnitType==PRIEST) {
                        unitType=UnitType;
                        maxhp=20;
                        hp=maxhp;
                        coinCost=30;
                        foodCost=60;
                        att=1;
                        ac=0;
                        selected=false;
                        speed=2;
                } else if (UnitType==SMITH) {
                        unitType=UnitType;
                        maxhp=50;
                        hp=maxhp;
                        coinCost=165;
                        foodCost=50;
                        att=7;
                        ac=0;
                        selected=false;
                        speed=3;
                } else if (UnitType==MERCHANT) {
                        unitType=UnitType;
                        maxhp=30;
                        hp=maxhp;
                        coinCost=150;
                        foodCost=60;
                        att=3;
                        ac=0;
                        selected=false;
                        speed=3;
                } else if (UnitType==TANNER) {
                        unitType=UnitType;
                        maxhp=45;
                        hp=maxhp;
                        coinCost=130;
                        foodCost=40;
                        att=3;
                        ac=0;
                        selected=false;
                        speed=4;
                } else if (UnitType==HELOT) {
                        unitType=UnitType;
                        maxhp=25;
                        hp=maxhp;
                        coinCost=60;
                        foodCost=60;
                        att=7;
                        ac=2;
                        selected=false;
                        speed=6;
                } else if (UnitType==PIKEMAN) {
                        unitType=UnitType;
                        maxhp=25;
                        hp=maxhp;
                        coinCost=85;
                        foodCost=50;
                        att=8;
                        ac=2;
                        selected=false;
                        speed=5;
                } else if (UnitType==CATAPULT[SE]) {
                        unitType=UnitType;
                        maxhp=70;
                        hp=maxhp;
                        coinCost=250;
                        woodCost=150;
                        att=18;
                        ac=1;
                        selected=false;
                        speed=2;
                }
        }


This just screams "use an array" to me. Smile
DanShadow




PostPosted: Thu Apr 20, 2006 1:42 pm   Post subject: (No subject)

umm...I dont remember posting my source, did you decompile it?
Anyway.. yeah I know Embarassed I should have used an array, but I was having this problem (I created an (ie) Settler class within the main class, and made any new unit equal to that, but of course that cant because putting population[i]=Settler; would connect those two classes, and force them to 'share' the properties of a Settler instead of 'copy', hehe.), so I made a quick fix and just added that.. it was mainly for the fact my old high school teacher said I should put it that way.
But yeah, this game was written pretty badly, and I have learned from my mistakes.
Instead of connecting the Graphics2D console to different methods, I just used the paint(Graphics g) method to draw about everything Razz , and the mouseListener to deal with all mouse events, not branching them into seperate methods to deal with seperate events, lol.
DanShadow




PostPosted: Thu Apr 20, 2006 1:45 pm   Post subject: (No subject)

Oh, lol... I did post source, woops.
Yeah, I intended just to post the game and its classes for people to see the game itself.

[edits .zip file]
Display posts from previous:   
   Index -> Programming, Java -> Java Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: