[Solved] Put Building in the ground (Like RTS game)

Get help using Construct 2

Post » Sun Apr 13, 2014 10:29 am

Hi,

Currently i've making a game like RTS (Real-Time Strategy) game. Now, i want to add 'put the building' event. So, can you help me? Thanks! And Sorry for My English.
Last edited by Regga354 on Sun Apr 13, 2014 1:58 pm, edited 1 time in total.
Creating games makes your imagination realized
B
14
S
4
G
1
Posts: 55
Reputation: 1,130

Post » Sun Apr 13, 2014 12:01 pm

aren't you just spawning an image on top of the background. just keep a record of what buildings you have where and upon startup create all the need "buildings".
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Sun Apr 13, 2014 12:56 pm

Just do not forget to check for collisions before you spawn the building, otherwise you will end up with stacked buildings, one on top of the other.

My suggestion in steps:

Step 1 - every tick, have the new building sprite follow the cursor (MouseX, MouseY)
Step 2 - Make the new building 50% opacity.
Step 3 - every tick, check for collisions (AKA see if another building is already built on the spot you want to place the new one)
Step 4 - If step 3 has passed (no collisions), then make the building glow green.
If step 3 has not passed (collisions have turned up true) then make the building glow red and do not continue to step 5.
Step 5 - If step 4 has passed successfully and the player clicks the e.g.LMB, then make the building's X,Y the same as the MouseX,MouseY.

In general, what you try to do is a substantial process imo, not just a couple of quick events. You also have to factor in saving the position of the building if you want to create saved games or go back and forth between menus.
B
5
Posts: 20
Reputation: 370

Post » Sun Apr 13, 2014 1:56 pm

@rho @shirogr thanks for the reply! It's very Helpful :)
Creating games makes your imagination realized
B
14
S
4
G
1
Posts: 55
Reputation: 1,130

Post » Sun Apr 13, 2014 7:43 pm

@shirogr

that's not needed as this is an RTS type game... once a slot has been built, then there should be nothing else that can be stacked.. I've done something similar.. I have an array of (say) 10 locations with a value, and actually what I did is put the same image down on each square and then set the animation frame to the structure I wanted. that way they are actually always there, but frame 0 is empty. however the trick then becomes how to know which structure is there when you want to do something with it, then you use instance variables to track as well.

the above method is just a one event to create the display.. making use of it is something else..
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Mon Apr 14, 2014 12:21 pm

@rho

We do not know if Regga354 wants to make a slot based rts like e.g. Kingdoms of Camelot (in which case your method is better) or if he wants to make a RTS like Command & Conquer where there are no slots, the buildings have various dimensions and the player can pretty much build wherever s/he wants (in which case I think my suggestion is more appropriate).
B
5
Posts: 20
Reputation: 370

Post » Mon Apr 14, 2014 9:19 pm

@shirogr

gotcha... I hadn't thought about a slotless implementation. good point
B
7
S
3
G
1
Posts: 184
Reputation: 1,352


Return to How do I....?

Who is online

Users browsing this forum: el3um4s, marcinkowski, marcoscodas, Ryan Kocourek, TheSupreme, TylerJS, Yahoo [Bot] and 8 guests