New person type question concerning RTSs

For questions about using Classic.

Post » Sun Jan 25, 2009 12:27 am

So, new to the construct after have a friend suggest it in another forum. Sounds like exactly what I want- a Python 'library' (yes, I know) that makes 2d HW accelerated graphics easy. However I'm a bit confused with some things.

For an RTS, how does one go about the data structures? MY idea was for an easily moddable game using text files, so it would load the unit information, and files ahead of time, and have unit classes like so [pseudocode]
class sprite:
object x
object y
image = spritename

class ground_unit(sprite):
objectHP
object dX
object dY
etc etc, methods for dealing with movement, etc.

From the ghost shooter tutorial on the wiki, and looking at the RTS sample built in, I wasn't able to get much. And I just have no clue where to start.
B
1
G
3
Posts: 7
Reputation: 839

Post » Sun Jan 25, 2009 12:40 am

you can write/read to/from .ini files as if they were .txt files
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Sun Jan 25, 2009 12:57 am

Thanks for replying:

Thats a good start. Now the next part is how I would organize unit variables. I've toyed around with C#/C++/Python and SDL/OGL/XNA trying to figure out how I plan to do graphics, as I feel about as confident as a newb can feel at the languages themselves. So trying to figure out actual programs like construct/GM/whatever is a bit tough :P
B
1
G
3
Posts: 7
Reputation: 839

Post » Sun Jan 25, 2009 1:04 am

Check the wiki for families, and containers.
Oh, and did you look at the rts template?
Image Image
B
161
S
48
G
89
Posts: 7,345
Reputation: 66,245

Post » Sun Jan 25, 2009 1:18 am

How to organize unit variables?

Never made any RTS, but I think it'd be a good idea to make use of HashTable object / Ini object to store some game configuration data like:
- game speed
- gamma correction
(name: "AppConfiguration")

Another HashTable object / Ini object to store units constant configuration:
- unit starting HP (when new object created, set its HP to this value)
- unit cost
- unit speed (when new object created, adjust its maximal speed and stuff to this value)
- unit armor class
- unit damage
(name: "GameConstant")

Another one for storing varying game data like upgrades.
(name: "GameState")

And provide every unit with set of Private Variables that are unique for every instance:
- unit HP
- unit Order Type (move/attack/gather/stop/hold)
- unit Referenced Object (like pointer to enemy object for attacking or resources object for gathering etc.)
- unit Destination Position (if not ordering to go into another unit but on "clean" location)

Saving/loading game is quite easy because all object's transferring private variables should be done automatically (haven't tested yet).

If you're familiar with programming, then it's quite simple to imagine that you can handle game logic with "foreach object" easily and access objects through their Unique ID like substitute for references.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Sun Jan 25, 2009 4:19 am

Construct is mainly an event-based programming tool, as you will see if you look through the examples and tutorials. Python is designed to circumvent the limitations of events.

However, I'm making a fairly large RTS in Construct, and I get by fine with simply a combination of families, containers, and private variables. Look them up on the wiki for more info. And as newt said, definitely check out the RTS basics template.
Scirra Founder
B
357
S
214
G
72
Posts: 22,945
Reputation: 178,206

Post » Sun Jan 25, 2009 1:08 pm

Thanks for the replies:

I was wondering about how the python script integrates. The article on it said that it can access things in construct by their names, but heres my questions:
1)Can a single complex script replace all events?
2)What are the limits of what the script can do? Can it call new sprites into being? Load new resources into the game? Will it allow you to use C code (I found a wonderful bitmask pixel-perfect collision detection library that even reports the coords of the impact)?

Let me describe more in depth what I'm looking at:
I want to make a WWII STYLE RTS that lets you customize units. Soldiers are simple enough, just choosing some equipment. Vehicles however are customizeable in size, location of innards (drag and place on internal grid). Weapon strength is based on the weapon and shell, it uses fairly 'simple' formulas (still going to need psycho for machine versions) for all the large projectiles to give them realistic properties, such as loss of speed based on current speed and weight. This is mainly what I consider a "warm up" concept for what I really want to do; it does not have to be a fully functioning RTS, just proof of engine.
B
1
G
3
Posts: 7
Reputation: 839

Post » Sun Jan 25, 2009 1:22 pm

[quote="Darkone":1nacvv14]1)Can a single complex script replace all events?[/quote:1nacvv14]
Generally, no. Python can access objects, but not all features are available through python yet (eg. behaviors). This is why I state Construct is an event-based tool, the event features are mature, and the python features are still "beta".

[quote:1nacvv14]2)What are the limits of what the script can do? Can it call new sprites into being? Load new resources into the game?[/quote:1nacvv14]
You can create objects, and you can use the script versions of the event actions which load resources from files.

[quote:1nacvv14]Will it allow you to use C code (I found a wonderful bitmask pixel-perfect collision detection library that even reports the coords of the impact)?[/quote:1nacvv14]
No, that's something completely different, although you can use C++ in the Plugin SDK and make a new object. By the way, Construct has an MMX-accelerated pixel perfect rotatable bit mask collisions engine, and I don't know of any faster engine. I'd be interested to know which engine you're talking about because if it's faster/better, I can think about improving Construct's collision engine. Also, normally it is not possible to accurately report the co-ordinates of an impact since a collision usually involves one or many regions of overlap, and even just taking a simple average causes the collision engine to be slower, because it can't stop as soon as it finds one case of an overlapping pixel.

There's nothing in your game spec that can't be done. You just have to put in the work hours to make it.
Scirra Founder
B
357
S
214
G
72
Posts: 22,945
Reputation: 178,206

Post » Sun Jan 25, 2009 1:36 pm

Gotcha. Didn't know much about constructs pixel perfect collisions. The files are simply called 'bitmask' and I think thats the name of the project. I'll upload it, as the school page it was hosted on is 404 now. It reports points of overlap in total /I THINK/. Its features page described it as being able to report overlap/point of collision and number of overlapping.

Edit:Screw it, files small. Stuck it in a .jpg

Save it, rename it to .rar.

Edit:Also, checked out containers and families. Interesting ;)

Another Edit: If I want to create a python method, is there an object in construct for that, or do I write it in script? IE, a method that determines how fast soemthing decellerates? Or should I do it inline like the action of "sprite.speed - (.....)? I'm jsut trying to figure out how to keep some good habits :P Edit:err..... what about using physics? Sorry, don't want to make new posts for every question I have.
B
1
G
3
Posts: 7
Reputation: 839

Post » Sun Jan 25, 2009 2:03 pm

Python's not working atm, but there still exists ways to event all of that, and as far as physics goes there is a behavior for that as well, although not all the behaviors work together.
Be sure to also check the wiki on time.delta

You should really take a good look at how events work, if you like Python, you'll notice a huge similarity.
Image Image
B
161
S
48
G
89
Posts: 7,345
Reputation: 66,245

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest