Minimaps?

For questions about using Classic.

Post » Sat Dec 17, 2011 10:27 pm

How would one go about creating a minimap/radar that sticks at the corner of the screen and only displays some objects on it? mogey2011-12-17 22:28:03
B
4
G
1
Posts: 50
Reputation: 652

Post » Sat Dec 17, 2011 10:45 pm

Since I collect all usefull .cap files the users post on the forum, I also have a minimap example. I didn't made it. Here's the link ->

http://dl.dropbox.com/u/26932498/minimap.cap

edit: unbelievable! found the old thread xD Credits goes to Mipey!
http://69.24.73.172/scirra/forum/viewtopic.php?f=8&t=5867zyblade2011-12-17 22:49:24
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun Dec 18, 2011 3:27 am

Also, do you have any links to a tutorial that explains how arrays work? I'm confused by them.
B
4
G
1
Posts: 50
Reputation: 652

Post » Sun Dec 18, 2011 3:34 am

Tulamide explained once in a very good way the basics of an array:



[QUOTE=tulamide] [QUOTE=Juryiel] ...what does it buy me over just using a 3D array such that one index is the Object.UID, the second dimension is the variable name, and the third is the value? [/QUOTE]
That's not the way, arrays work. An array is just a line of cells, and you access those cells by using coordinates. Whatever count of coordinates you have, it leads to exactly one cell.




So, to access the data you need to do something like this: var = array(2, 1, 4)
To store a value it is: array(2, 1, 4) = "one cell"

....
[/QUOTE]

If you want to read the whole thing(but the rest isn't about the array itself):

http://www.scirra.com/forum/container-type-functionality-for-families_topic46974.htmlzyblade2011-12-18 03:36:05
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun Dec 18, 2011 3:46 am

I also made a more complete tutorial about arrays and hash tables a year ago. It includes demo caps besides the written explanations.

http://www.scirra.com/forum/tutorial-variables-arrays-hash-tables-an-overview_topic41773.html
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sun Dec 18, 2011 4:00 am

<offtopic> What would we do without Tulamide? </offtopic>

You allways have interessting stuff off pat^^
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Sun Dec 18, 2011 4:42 am

:D Thanks a bunch zyblade and Tulamide!

Also Tulamide, so your example cap for the array is basically writing data to the array that stores the animation frame its on? And how would I go about creating an inventory using an arrya, would I write a variable to an X,Y position on the array? Or would using 'S' be more useful for this?mogey2011-12-18 04:56:07
B
4
G
1
Posts: 50
Reputation: 652

Post » Sun Dec 18, 2011 11:11 am

[QUOTE=mogey] :D Thanks a bunch zyblade and Tulamide!

Also Tulamide, so your example cap for the array is basically writing data to the array that stores the animation frame its on? And how would I go about creating an inventory using an arrya, would I write a variable to an X,Y position on the array? Or would using 'S' be more useful for this?[/QUOTE]

It depends on how your inventory is organized and what information has to be saved. Use an array whenever you can map a situation in your game directly to a bunch of cells. For example, if your inventory is a bar with a fixed number of slots, it is very easy to map slot a to cell 1, slot b to cell 2, etc.

If your inventory is more like in an rpg, a bag that can store a non-fixed number of objects, then a hash table would be more suitable. You could create a key with the name of the object and a value representing the id or position in the bag's list.

You can always store more than one information at once. Just use strings instead of numbers. In an array, you could fill a cell with the string "Green Pill, 25, 12.52, C" and later extract the informations using the expression 'get token'.

But if it is a really huge number of informations that needs to be stored per inventory slot, you might indeed consider using 's'. With its ways to create data structures and reference them in other superstructures, it is way ahead of any other method in Construct, as soon as something is object oriented.tulamide2011-12-18 11:12:23
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sun Dec 18, 2011 4:53 pm

I guess I'll go with the array then, however when storing values in the array can you use strings? Or do you have to use integers. Also how do you access the array using construct's expressions.

Having a problem now, I added a condition to shooting to check if the index 1 is equal to 1, then allow the player to shoot. I also set up an event so that when the player collides with the rifle pickup it sets the index 1 to 1. Yet the player still cannot shoot.


By the way I know that using global variables for this would work and be much easier, but I want to learn arrays.

Also, how would I add vehicles that the player can enter and leave?mogey2011-12-18 20:04:57
B
4
G
1
Posts: 50
Reputation: 652

Post » Mon Dec 19, 2011 7:02 pm

[QUOTE=mogey] I guess I'll go with the array then, however when storing values in the array can you use strings? Or do you have to use integers. Also how do you access the array using construct's expressions.[/QUOTE]

This cap will answer the questions: access_string_array.cap
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests