Wave logic with images
RUPAS
Member Posts: 823
Hello friends, I have a problem that I can not solve, I was wondering if someone could help me. But the problem is this, I have an images that change depending on the tables, ie
Row 1 - picture 1
Row 2 - image 2
Row 3 - image 3
etc
the problem is that I have a rule that all pictures will rotate the rule is as follows;
whats image to (whatimage +1)% 3
the problem is that when images are changing with this rule there is one moment it reaches 0, then as in tables no column 0 shows no image. Because the loop with that rule is (0,1,2,0,1,2,0,1,2 ......)
The question is, there a way that is (1,2,3,1,2,3,1,2,3,1,2,3)?
Thanks!!
Row 1 - picture 1
Row 2 - image 2
Row 3 - image 3
etc
the problem is that I have a rule that all pictures will rotate the rule is as follows;
whats image to (whatimage +1)% 3
the problem is that when images are changing with this rule there is one moment it reaches 0, then as in tables no column 0 shows no image. Because the loop with that rule is (0,1,2,0,1,2,0,1,2 ......)
The question is, there a way that is (1,2,3,1,2,3,1,2,3,1,2,3)?
Thanks!!
Comments
Hi @RUPAS try this:
Change attribute whatimage to (whatimage+1)%4
Rule: When whatimage = 0
Change attribute whatimage to 1
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Very nice looking image, btw...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Here's my test file, for your interest (showing the loop, no images though):
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
The following works for me for looping 1,2,1,2, etc:
Change attribute whatimage to (whatimage+1)%3
Rule: When whatimage = 0
Change attribute whatimage to 1
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Hi @RUPAS I was wondering, right from the beginning of your thread, why you're using a table at all when you have so few images....
So you could try one of the following:
Rule: When touch is pressed
Change attribute whatimage to (whatimage+1)%4
Rule: When whatimage = 0
Change attribute whatimage to 1
Rule: when whatimage = 1
Change Image to yourimage1
Rule: when whatimage = 2
Change Image to yourimage2
Rule: when whatimage = 3
Change Image to yourimage3
----------
Actually, if you're no longer using a table for this, could be simpler now, of course:
Rule: When touch is pressed
Change attribute whatimage to (whatimage+1)%3
Rule: when whatimage = 0
Change Image to yourimage1
Rule: when whatimage = 1
Change Image to yourimage2
Rule: when whatimage = 2
Change Image to yourimage3
-----
or:
Rule: When touch is pressed
Change attribute whatimage to (whatimage+1)%3
Change Attribute: self.image to "MyPic"..whatimage
-------
or, without the modulus, of course:
Rule: When touch is pressed
Rule: When what image < 3 --- for 3 image loop
Change attribute whatimage to whatimage+1
Change Attribute: self.image to "MyPic"..whatimage
Otherwise
Change attribute whatimage to 1
Change Attribute: self.image to "MyPic1"
------
Then providing yourimage3 is the same as your start image, it'll loop nicely, without the use of a table. Just a thought.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@Digi-chain has a system like that I want to do, I have asked for help twice, but I never responded .... I would like him to help me
Some of the straightforward rules I suggested can be utilized for an inventory system; I know, because one of my many games on the back burner is an adventure game, where I finished an inventory system with rules similar/including. (Here's a vid. for interest, although at this stage, the inventory system wasn't complete):
OK. :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Just realised: I guess you're talking about the type of inventory system in @Digi-chain's excellent point-and-click game Spooky Manor, where a forward button is pressed, and the item image changes each time in another actor; if so, I'd approach it something like this:
• Set up your table (I see it's best to have a table now if you're dealing with an inventory, and will make for easier adding and deleting items; rules not shown for that but I'm sure you're OK with that side of things). Make your column as Text, put in the names of your items. (Also make sure these correspond exactly with the image names of the items in the Library).
• In your forward button (which can be amended for use in a back button, if required) put:
Rule: When touch is pressed
----the following loop is outside of the change attribute for changing the name of the item, and doesn't use the modulus, because I couldn't get it to work using that method, i.e in the expression editor)---
When Attribute MyItems < 5 (--- 5 in this case, being the max. amount of items in table list; change accordingly, of course)---
Change Attribute LoopGo to true
Change Attribute MyItems to MyItems + 1
Otherwise
Change Attribute MyItems to 1
Rule: When touch is released
Change Attribute LoopGo to false
----------
• Now in the actor to show the inventory items as images:
Rule: When LoopGo is true
Change Attribute self.Image to tableCellValue(game.YourInventTable,scene.MyItems,1)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Hi again @RUPAS, I understand what you're saying...
OK, this is it roughly: Firstly, if you have all your items in the table to start, but only some of them are visible to use, and then some more are added to be used, and others to be hidden when they've been used; in this case I would recommend a second column in the table, values as booleans. Those that can be used/seen will be true, those that can't will be false.
This aspect then needs to be added into your rules for looping through just the true items, as well as for changing the item true or false accordingly, as and when. Also don't forget to change the total number of available items when these booleans are changed.
-----
A second way would be to just have only the amount of items that you start with in the table; then when an item needs to be added or deleted, you use the Add/Remove Row behaviour (as well as Change Table Value behaviour). Again, if you use this, don't forget to update the total amount of available items in the attribute (MyItems, in my example). I'm thinking that this way would be easier...
I hope that's guided you in the right direction.
PS Just a small correction to my example before: it's best that MyItems is a game attribute rather than a scene one... but I'm sure you caught that.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Glad I could help, @RUPAS :-) And best of luck getting your new game together; by that sneak peek, it's looking the business!
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps