Game Development Community

Help with Tycoon Style Game

by Night Fox · in Torque Game Builder · 12/29/2008 (8:56 am) · 53 replies

Like the title says I've been assigned to do a Tycoon style game.

I've chosen TGB to design it and have the basic art necessary to make it works.

Heres the concept.

A player is given time and 4 team members to create a final product for a client.

The player may put team members into 3 different buildings, or place them all into one single building, each building offers a special function.

Reserch Building - When a member is placed here they earn RP. The more members placed here the more RP is accrued.
RP is neccesary to unlock the Development Building, and to Remove Troubleshooting Points or TP for short.
1 RP is earned for every Second (For now)

Development Building - Members placed here spend RP to earn DP. Once Dp = 100 points the product is complete and the player wins.
Let us say it cost 100 RP to unlock the doors to the Dev Building, then it cost 2 RP to gain 1 DP.

Now Development alwasy has kinks so I thought up Trouble Shooting Points or TP.

Troubleshoot Building - Members placed here spend RP to remove TP. When TP appears Development is halted until TP is removed. To keep it simple, it cost 2 RP to remove 1 TP. Once TP is fully removed Development points can be acquired again.
TP points are random ranging from 10 to 100. For now it can happen only once, later I'd like to have it happen at random intervals, maybe after Dev Points are being earned the game will see if trouble happens on a 1 minute basis.

So thats the gist of the game I've concepted and need to finish, I've got about a month to do it and would really appreciate any help possible!
Page «Previous 1 2 3 Last »
#1
12/29/2008 (12:02 pm)
I'd recommend starting by creating a couple of polygons that represent each of your different buildings, then add some basic images to represent the team members.

From there work on to core gameplay like you discussed in your post, keep it very simple and forget about artwork, focus on getting to grips with the scheduling system and basic gui in TGB and the logic of locking/unlocking the buildings according to the values built in the other buildings.

Once you get an 'economy' system going, then you can easily tweak the balance of the point systems and how the player will build their points to create their 'product'.

Best of luck,
Patrick
#2
12/29/2008 (1:18 pm)
Thanks for the reply.

I've already fabricated some buildings and icons. Plus using the behaviors I was able to get a timer system which ends the game when it hits 0 seconds.

So now my first step is just research.

I can see how it works, I just fail at actually typing the code.

I understand that when the button is toggled it will cause an increment of 1 point of Research a second. From there I understand that the toggle for devlopment should be unlocked.

I found a helpful tutorial on making a scoring system, and I think I can jury rig the code to where it will work. This all depends on two things, one is I don't know how to make a toggle button (and the Behavior button is limited, if it could be made to toggle I bet I and many others would be happy)
2nd is actually allowing the second building (Dev) to unlock.

For now I'm gonna play the KISS game and start with 1 research building, and 1 dev building, and the player has only 1 team member to boot around.

Adding the team to the building sounds understandable, when Research box is toggled, decrement the players team number, when the box is un-toggled then increment the players team number by 1.

Sorry if sounds a bit exhausting to read, as I've said I can clearly see how it should work, but the process of actually typing it is very difficult to me 8( I have the utmost respect to the coders here who can easily whip out solutions! Cause this is some tough noggin grinding work!
#3
12/30/2008 (8:36 am)
I've chosen to put image maps that can be toggled rather than using the GUI Editor, cause I find the GUI editor a bit overwhelming at the moment.

How would I apply a toggle effect so that when the image is clicked it will become image2 and when clicked again it reverts back to image 1.
#4
12/30/2008 (9:04 am)
I'm unclear on what you're doing but Ill give you some options...

If you are using a gui button, check
here.

--In the command section of the datablock, call the function you want.

If you're using an image that you want to execute something when you click on it, then you want to use the onMouseUp() callback, as thoroughly described here.

--Put the code you want in the onMouseUp callback.
#5
12/30/2008 (9:24 am)
Cool this helps explain the GUI system better to me, it'll help later in the menu creation.

So far to better explain. There is a button that represents Research. When the button is clicked it will switch from its base image to image2, very similar to the GuiCheckBox. This represents the team member being assigned to the research field.

I wanted to see if I could do some type of true false switch where 0 means the icon has not been checked so do not increment score, and 1 means that the icon has been checked so increment score by 1.
#6
12/30/2008 (9:47 am)
I'm still unclear if you're using a gui button or not but it doesn't sound like it. Although, it seems that what you're trying to accomplish would be be handled through the gui but if you are using a t2dSceneObject (or some subclass) then give something like this a shot:

In TGB select the object you want to use as a button and go to the scripting section and assign it a class such as "buttonClass".

Then create a script called 'input.cs' in the gameScripts directory and make sure you execute it from './game/main.cs' using:

exec("./gameScripts/input.cs");

In input.cs, paste the following:

function buttonClass::onMouseDown(%this, %modifier, %pos, %clicks)
{    
     if(imageName1.Visible == true)
     {
           imageName1.setVisible(false)
           imageName2.setVisible(true)
     }
      else
     {
           imageName1.setVisible(true)
           imageName2.setVisible(false)
     }
}

Please note that this is untested and for the above code to work, you would need to have two images named imageName1 and imageName2 in your level.

Hope it helps,

Patrick
#7
12/30/2008 (10:23 am)
I believe this is exactly what i'm looking for!

I can set the score system based on whether or not an images .setVisible is true or false.
Thanks this will help greatly.

I should be safe changing imageName1 to the name of the image I have already uploaded correct? Same for imageName2 right?

Currently I've two images one called Research and another one called Research_Toggled
#8
12/30/2008 (10:24 am)
You got it...
#9
12/30/2008 (11:35 am)
Okay so apparently it doesn't want to play nice (just my luck)

In the console it reads

Unknown command setVisible.

function buttonClass::onMouseDown(%this, %modifier, %pos, %clicks)
{
echo("Clicked");
if(Research.Visible ==(true))
{
echo("Change1");
Research.setVisible(false);
Research_Toggled.setVisible(true);
}
else
{
echo("Change2");
Research.setVisible(true);
Research_Toggled.setVisible(false);
}
}

So far with the above code it calls the echo "Clicked" and the echo "Change2" so I know its at least looking at teh script.
#10
12/30/2008 (12:39 pm)
Most likely you did not actually name the image. I don't mean filename here...

In TGB, drag the image into your level, select it, then go to the scripting rollout on the right side. Under name, put: Research

Or, if you fear the editor, you can open you level (untitled.t2d by default) and you should have something like this, but with your data in it:

new t2dStaticSprite(Research) 
{
      class="ButtonClass";
      imageMap = "filename";
      frame = "0";
      canSaveDynamicFields = "1";
      Visible = "0";
      size = "75.000 75.000";
      Layer = "26";
         mountID = "6";
};

Also, you don't need the parenthesis around "true" in your if statement... not sure what that will do.
#11
12/30/2008 (12:58 pm)
New t2dStaticSprite(ResearchImage) {
imageMap = "Research";
frame = "0";
canSaveDynamicFields = "1";
class = "buttonClass";
Position = "-5.500 -16.500";
size = "6.250 5.250";
mountID = "4";
};

Okay so I double checked and made sure that it was right, I had the name added in the name field.

Then I tried turning use Mouse events on and then off, when its off I get no response at all so I figured it was necessary to keep on.

heh I think its just the artist in me creating this problem 8)
#12
12/30/2008 (1:15 pm)
So you got it working?
#13
12/30/2008 (1:22 pm)
Unfortunately not
Console reads

echo Clicked
echo Change2
game/gameScripts/input.cs (27): Unknown command setVisible.
Object Research(1291) Research -> t2dImageMapDatablock -> t2dBaseDatablock -> SimDataBlock -> SimObject
game/gameScripts/input.cs (28): Unknown command setVisible.

I've got to pull out from the pc now so I'll have to check back later tomorrow.

Till then I'm going to apply my head to a hard wall for some tough defragmentation.
8)
Again thanks for the help!
#14
12/30/2008 (1:39 pm)
Remember, you need to apply setVisible to the name not the imageMap.

ResearchImage.setVisible(true);
#15
12/31/2008 (6:33 am)
Heh so after some minor wall to head defragmentation I got my wits about me and reread the entire post again.

I gave the images the proper name, and it worked. Kinda!

The image clicked, image1 became invisible and image didn't appear, so I was wondering what the heck when it hit me, I need image two to already be on the field (which it was thank god) but to also be in the exact same location.

A quick change of XY coords and its all fixed!

Now since you've helped me with the true false setting of the code, I now gotta add the incremental count up for the Research Points. So I'm going to check the countdown timer tutorial and see if that helps me!
#16
12/31/2008 (7:43 am)
Glad to hear it's working for you!
#17
12/31/2008 (8:35 am)
Alright so the mini tutorial GUI score and time is well, for the gui.

Now since the text tool in TGB is considered to be an ingame object rather then a GUI object, the idea behind the tutorial could not be applied to the game could it?

So far this is what I've dropped in code, obviously this wouldn't work but as I said I'm taking micro steps to fully understand what i'm doing!

function buttonClass::onMouseDown(%this, %modifier, %pos, %clicks)
{
if(Research.Visible == true)
{
Research.setVisible(false);
ResearchToggled.setVisible(true);

echo("People Count take away 1 point");
PPoints.setValue(PPoints.getValue() - 1); //we lost our team member
}
else
{
Research.setVisible(true);
ResearchToggled.setVisible(false);

echo("People Count put back 1 point");
PPoints.setValue(PPoints.getValue() + 1); //team member returns
}
}

Now since the mouse down works, I am currently working on the people count first, rather then the research points.

I've a text object named PPoints. Just in case I've given it a class peoplePoints. Now after following the GUI tutorial it worked fine, then when I applied that tutorial to my game it caused some bugs, due to the test object being a sceneobject rather then a gui object.

Just so i didn't lose anyone, PPoints represents your team member, when the game starts you begin with 1 team member, when the research image is clicked the team member is added to research thus you lose 1 team member. When research is clicked again the team member is added back to your que (you gain that lost 1 point back)
#18
12/31/2008 (9:10 am)
Scratch that last post, I'm going to try and use the GUI system instead, that way I am able to learn all aspects of TGB. This should keep me from overcompensating for more simple code.
#19
12/31/2008 (9:43 am)
I've never used a textObject actually... You're really going to want to do this in the gui. It's quite simple actually.

Open TGB, hit F10 to bring up the GUI Editor.

Open mainScreenGui.

Toggle the tools pallate in the upper right.

Drag a guiTextCtrl from the toolbox to your scene.

In the rolldown on the right, give it a name like: 'pPointsGui'

Save, overwrite mainScreenGui and hit F10 to exit the GUI Editor.

Now in you code, just do this:

function buttonClass::onMouseDown(%this, %modifier, %pos, %clicks)
{
if(Research.Visible == true)
{
Research.setVisible(false);
ResearchToggled.setVisible(true);

echo("People Count take away 1 point");

//we lost our team member
$teamCount--;
pPointsGui.text = $teamCount;
}
else
{
Research.setVisible(true);
ResearchToggled.setVisible(false);

echo("People Count put back 1 point");

//team member returns
$teamCount++;
pPointsGui.text = $teamCount;
}
}

A couple things in that code to note... a variable with a $ before it is a global variable and can be accessed throughout any function. Overusing these is frowned upon in programming, but for simplicity's sake, I'm going with it.

$teamCount++ will increment the value by one, $teamCount-- decrements.

ps... please wrap your code in code tags, it makes it easier to read.... check here to learn how.
#20
12/31/2008 (12:24 pm)
Ahhh thats an interesting way to put it!

Lost internet for a bit but I was able to find a work around using the gui tutorial, had to actually learn the gui system but hey thats what its there for right!

in input.cs I had modified the buttonClass like so

function buttonClass::onMouseDown(%this, %modifier, %pos, %clicks)
{    
	if(Research.Visible == true)
	{
		Research.setVisible(false);
		ResearchToggled.setVisible(true);
		
		echo("People Count take away");
	
		// increment scoreboard score field
		teamNumber.setValue(teamNumber.getValue() - 1);
	}
	else
	{
		Research.setVisible(true);
		ResearchToggled.setVisible(false);

		echo("People Count put back");
	
		// Decrement scoreboard score field
		teamNumber.setValue(teamNumber.getValue() + 1);
	}
}

Having your mouseDown code really helped by the way.

Then I went ahead and added+modified the tutorial code into the game.cs

// scenegraph onLevelLoaded callback
function t2dSceneGraph::onLevelLoaded(%this)
{
	// schedule the timer update function for 1 second
	%this.timerSchedule = %this.schedule(1000, updateScoreboardTimer);
}

// scenegraph onLevelEnded callback
function t2dSceneGraph::onLevelEnded(%this)
{
	// cancel the timer update event if it's currently pending
	if(isEventPending(%this.timerSchedule))
		cancel(%this.timerSchedule);
}



// updateScoreboardTimer function
function t2dSceneGraph::updateScoreboardTimer(%this)
{
	if(Research.Visible == true) //used from the buttonClass code
	{
		// increment scoreboard time field
		researchPoints.setValue(researchPoints.getValue() + 0);
	
		// reschedule ththis function for 1 second
		%this.timerSchedule = %this.schedule(1000, updateScoreboardTimer);
	}
	else
	{
		// increment scoreboard time field
		researchPoints.setValue(researchPoints.getValue() + 1);
	
		// reschedule ththis function for 1 second
		%this.timerSchedule = %this.schedule(1000, updateScoreboardTimer);
	}
}

So not only does the RP count up when the member is added, but it counts how many members are left in the group!

I think I see a way of setting a lock on the Dev building. I saw the use mouse events line of code.
So what'll do is set the Dev button to 0 and turn it on once resource = 100 that should hopefully work 8)

Heh I'm happy I'm actually understanding this slowly!

Also I was going to ask how one puts the code into those nice organized buttons, but now I know!
Page «Previous 1 2 3 Last »