3dski's Recent Forum Activity

  • Sorry, but this isn't actually a reply, but a relate question concerning the main topic. I've created a family of individual sprite objects. It looks pieces.X and pieces.Y ("pieces" is my family of sprites) would pertain to each individual sprite in the Family, so I could set an event for a sprite at X and Y equaling some other X and Y using a "For each" loop. My problem is, though it might catch that "pieces" member, it doesn't expose the an instance variable I've set in each of the sprites in the family, which total messes up my idea of why a "For each" would be useful... looping to find an object, then querying it for information. Yes it kind of seems to do that, but not to the degree that I need.

    Its aggravating that I currently have to explicitly test each position of every "piece", in order to retrieve and use its instance variable to perform other actions. I need a way to loop through a set of objects, which I know I've set that instance variable on, find the one I want, and set the value of that instance variable into an array.... "You can't do that Dave." Anybody have an idea... is there an alternative plugin that will allow this kind of individual object access in a "for each" type of loop? BTW, each object (sprite) is similar, but unique in appearance. The same instance variable is defined on each of these, with the value I need. I guess what I'm trying to stress is, the sprites are not simply clones of some single sprite instance (if I'm describing that properly). Thanks!

    [UPDATE] I solved my problem. I first shortened my list of positional checks by doing a "Pick by expression", which allowed me to grab the object I wanted out of my "pieces" Family, at X Y location in one line. Then, I realized that I already had the value I was looking for in an array, at the index I was passing to the function where my processing was. So, instead of depending on the instance variable, I could simply use the value at an array location using an index I was already being passed.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • SOLVED: First, to clean up my event sheet, instead of using different flags for different states in the game, I have 1 state value to check and set constants to represent each state, use to set "state" throughout the phases of the game. I had to learn how to properly/effectively use sub-events, under each event that is used to test the current value of "state". Also learned how to implement loops, which solved another problem. There was also a lot of repeated logic for each color, so I learned how to create functions to reuse that logic.

    Finally, to solve my turn taking problem, I simply move the target slots up (they're at the bottom of the screen). Then movement of a color is done by spawning a dummy instance of that piece at the working piece's position, then moving the working piece to the target. So, in this fashion, each turn can always use the same slots and pieces.

    So, I made a lot of head way and feel much better about Construct 2. There are some things you have to shift in your brain if you're a traditional coder, because you have to be more particular about how you implement things in the event sheet. I'm now at point of just figuring out what I want to do at the WIN and LOSE states of my game.

    And, though I have plenty of experience programming (25 yrs), this will be my first COMPLETED Construct 2 casual game. My goal is learn how to wrap it as a hybrid app for android and test it on a device or 2 (phone and table). Then, make any adjustment to the code to better fit on both devices.

  • The RandomArray plugin may solve the issue, but depending on your implementation, it may not be necessary....

    I've accomplished a solution without RandomArray and I think its straightforward and clean. Rather than fill the temp array used in the randomization process, you simply create a new one and fill it. After the randomization process, it's virtually nothing (0 length), so you destroy it. But, remember, this is just a working copy, so the original one is still there to create from.

    Another solution may be, to work with an empty array instead of presetting the arrays size. Then, instead of initializing values at different positions, you'd simply push the values into it. If this solution works, you don't ever have to recreate the initial temp copy of the array, but simply re-push initial values into it for the randomization process.

    Initially, I did see the array was still there, but of 0 length, but I failed to make the connect to the push method, because my brain was stuck on setting the values by index. So, think push, instead of set.

  • My question actually has several parts. First, I understand drag and drop behavior, but decided I didn't like it, so opted for setting the selected item with a "-picked" flag (red-picked=1, blue-picked=1, etc.) The first issue I have is, I used to standard programming, where I would just get a reference to the object clicked on, then on then check if the place to drop is a good spot and place it. In this environment, and for my situation, I'm having to repeat the same initial object selection for every single item (there are 4), and for each of the 4, I have to set ALL the "-picked" flags accordingly. I don't know if I can implement this with a group somehow to minimize the code. The point is, I only care that one of the items was selected, then move that item to the next spot that the mouse has selected. In summary, I managed so select an item by clicking and move it to the destination, but the code for working with 4 different objects seem like overkill and would like to optimize it if I could.

    Next problem... what I'm creating is like the a game that I think was called, Master Mind. There would be a hidden combination of 4 color pegs. You have perhaps maybe 10 chances to guess the proper order of the colors. So, I have to check that all 4 colored sprites have been moved, then test for correctness, then allow them to be moved again if they were incorrect and they have turns left. The destination for the moves from one iteration to the next are simply a set of sprites, and these can me moved forward for the next move if the user fails to guess the correct order. And, I already know how to select->drop (as cluttered as that seems), but my bigger problem is, I'd like to leave the current colors at their current locations and place a spawned copy at the target location for the next move, so the user can see all there previous tries. This suggests some kind of spawn operation, but then the complication is, all of the older copies cannot be selectable! Do I restrict the click by Y, since each try moves vertically up the playing field, so only the sprites near the top can be moved (If mouse clicked -and- Mouse.Y > blahblah | set color's to picked flag)?

    In the meantime, I'll keep trying alternatives, but any suggestions would be great! One thing I'm trying to wrap my head around is, if I spawn a bunch of red items, and they click on a red item, then how will it know which red one to move to the target location.... and thus this multiplied times 3 other colors involved.

    BTW... I currently don't uses instance variables, but these might help, solve some of my code blot, by being able to implement my objects differently, and be able to loop through set of them and examine their instance variables, for values that would help me determine the processing that needs to be done, and help me identify the object to act upon.

  • I realize that my comment is a bit off topic and it won't answer your question, but I'm new to all the options of programming games for online/mobile access. One thing that sticks out in my mind is, the companies that state that you can hand them a ZIP of your HTML 5 project and they'll "wrap" them for mobile use... but, this relates to pushing your game to stores yourself (not doing work for another company). But, I can imagine larger companies having tested particular HTML 5 frameworks/engines and having an investment in the tools they used that focus on those frameworks. I certainly don't know what the pie chart looks like for exclusive framework usage, but I can see where it would exist in cases where you're coding for them. You're question has got me interested in the what this pie chart might look like!

3dski's avatar

3dski

Member since 15 May, 2016

None one is following 3dski yet!

Trophy Case

  • 8-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

10/44
How to earn trophies