Add the sprite "info" from the last posted file.
Place it outside the canvas of the layout.
Name it "Vault". Size it if you feel its to big.
add 2 private variables to it
X_head, number, 0
Y_head, number, 0
Now we are set to take a new start.
back to the events editor.
Double click the action. Click back till we are in the first wizard step. (lazy editing
step1: self object = Vault
step2: action = set value
step3:parameters .. private variable = X_head .. value = 10
You see the eye catching thumbnail ? Much better then a black dot.
now we "lazy edit" some more
CTRL + drag the action under itself to copy it. I do advice to not use copy / paste short keys in present version of construct when dealing with actions. Sometimes the copy shows up on a random place in the events. If you have all events but the one you work on collapsed, then suddenly your
game is messed up, and u dont know why. Using CTRL dragging to copy actions.
double click the copy.
we land allready in step3.
change X_head to Y_head
change value 10 to 0
Lazy but fast. And more of this.
Select the on key event. (line 2 in the sheet). The event, not the condition. (E-spot)
They whole tree will go selected.
press CTRL+c, press CTRL+v
Now we have a copy of the event, including the actions.
Double click the condition in the copied event. Automatically we land in step3 in the wizard.
Change the right arrow to left arrow.
Change the X_head value directly in the action line, by clicking the value 10.
Change it to - 10
The value stored in Y-head stays the same 0.
Do the same for up and down arrow keys. (copy event, change condition, change values)
the values for the up arrow will be
the values for the down arrow will be
Do you see how fast you can code ? make events ? edit events in construct ?
This is another reason why i like it so much.
Now we translated directions, given by a key, directly to X and Y changes.
All we have to do know is move the head's position + the changes
right click the always event under the "move head" comment.
Add an "always" sub event.
give the sub event an action.
step1: self object = head
step2: action = set X
step3: parameters ... click the vault object in the expressions guide .. click the expression "get private variable" ... change the 'Variable name' to 'X_head' ..
so its Vault.Value('X_head')
add .X + in front of that .. so it is
.X + Vault.Value('X_head')
note to ashley : it would be nice if the wizard preselects the Variable name, would be very nice.
Copy the action.
Double click the copy
Click back to step 2 of the wizard. Select "Set Y" as action.
Click next. The expression is still there, just change X_head to Y_head and .X to .Y
And we can run and test.
Hey that works. But OMG, that snake is fast.
Lets slow it down.
Double Click the TOP "always" condition in the event that moves the Head.
it brings up the events wizard.
click back to step 2 of it.
step2: Choose "every X milliseconds as" condition
step3: change the default value 1000 to 100 (hundred)
DO you Understand NOW why i want you to open each tree of events with a "always" condition ?
Its easier to edit, organize 1 condition, then to add a level of events to a tree.
And the structure stays correct.
run all .. and ..
is this better ?
there is something else to solve though.