EDIT: Just found the solution after posting. If I change the order of the operations described below everything works fine. But I don't know why that is, if you could tell me?
Hi,
I just started working with MF2 and I decided to create some very simple games just to try out some basic mechanics. One of these games doesn't work fine.
This is what I want to do:
There is one active object either facing up or down.
When it's facing up you have to press ↓, its direction changes, add 1 to counter.
When it's facing down you have to press ↑, its direction changes, add 1 to counter.
When you press the wrong arrow key 1 is substracted from counter.
This is what I did to achieve this with a single active object and a counter:
+ Internal flag 0 is on
- set direction down
+ Internal flag 0 is off
- set dircetion up
+ Internal Flag 0 is on
+ Upon pressing "Down Arrow"
OR
+Internal Flag 0 is off
+ Upon pressing "Up Arrow"
- add 1 to Counter
- toggle internal Flag 0
+ Internal Flag 0 is off
+ Upon pressing "Down Arrow"
OR
+Internal Flag 0 is on
+ Upon pressing "Up Arrow"
- substract 1 to Counter
The problem I noticed is that 1 is always substracted from the counter no matter which arrow key I press. I helped myself by simply add 2 to the counter when you press the right key but I would like to know what I did wrong in the first place?!
I guess I am missing some very basic stuff here... I have to say I am new to programming so that might explain the stupidity of the question :)