Tycoon building game

Get help using Construct 2

Post » Tue Jan 22, 2013 1:56 am

I find this interesting and i havn't seen one around in c2, i've been looking for a rail tycoon sort of game for android but there is no good ones so i thought of making one , now how would i put it into code in c2, the act of building/stretching a railway where 1 block is 10x10 , in a straight line from 1 station sprite to another ? any ideas and opinions that could help my project?
B
1
Posts: 2
Reputation: 379

Post » Tue Jan 22, 2013 3:01 am

Just off the top of my head, you could try this to automatically set the rail section to the right piece (corner, straight, etc.) while dragging:

Whenever you create a new piece for the rail, spawn a detector object on all sides (set image points for left, right, top, bottom and spawn them on those). Then as you drag past and create a new piece, check which detector it's overlapping. With that information you can set the pieces of rail to the right animations (left corner, straight, etc.). Make sure to destroy all the detectors after a certain number of rails have been placed.

I'm just heading out the door, so sorry it's not very precise. If you want I can clarify a bit when I return. Good luck!
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Tue Jan 22, 2013 2:58 pm

thanks alot :D , and yeh please do explain as fully as you can if you have time , i am pretty new to c2 :)
B
1
Posts: 2
Reputation: 379

Post » Wed Jan 23, 2013 1:47 am

Now I haven't actually played that game, but imagine you click one spot and drag along and it creates track right?

First off when you create a new object for your track pieces, I suggest adding 1 animation for each piece of track you will have. So animation 1 is straight track, animation 2 is right corner, and so on. Now, on any frame of any animation, select the image point button on the left of the image window (looks like a little target).

When you click on that, a little window will pop up showing you the list of image points, the first one being called 'origin'. Now, add 4 more image points, and right click on them. Then choose 'quick assign' and make one left, one right, one top and one bottom, then name them appropriately. Once you have done them all, again right click each one and select 'apply to all animations'. And now you have image points on every side of every piece of track!

Now you do: 'is mouse pressed' + is overlapping track (inverted): create track (there are many ways to make the new track snap to grid, but I don't have time to go into it. If unsure, just look around the tutorials - there's a lot of info for it!).

Now create some small square images called 'detector left/right/etc.'. Give them the variable 'track UID'.

Then have an event: 'On track created': track spawn object 'detector left on image point 'left', 'detector right' on image point 'right', and so on. Then on detector created: 'set 'track UID' to 'track(track.count-1).uid''. This will make sure that they only affect the latest piece of track.

Now you can do something like:
'For each track: if detector left is overlapping track + detector left track UID = track.uid, detector up is overlapping track + detector up track UID = track.uid: set track animation to 'turn up''

This isn't 100%, you will need to decide many things like when to destroy the detectors, whether the track can split in 3 ways, etc., etc., but this is the general method I would start with.

Sorry I don't have more time to help, it does sound like a fun project to work on :)
B
27
S
8
G
5
Posts: 429
Reputation: 6,902


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 18 guests