not sure what's wrong

For questions about using Classic.

Post » Wed Dec 19, 2007 6:12 pm

the object moves a little bit but that's about it so i'm not really sure what i'm doing wrong so some help would be nice



P.S. i think my brain is turning into mush
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Wed Dec 19, 2007 6:20 pm

And what's the problem. Nothing moves?
B
2
S
1
G
5
Posts: 50
Reputation: 1,500

Post » Wed Dec 19, 2007 6:49 pm

oh yeah ... forgot to mention that XD told ya my brain was turning into mush LMAO
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Wed Dec 19, 2007 7:18 pm

Just some quick thoughts.

Remove the keydown checks in the loop. No need to check them again.

Must agility always be greater or equal to zero? Otherwise you could let key left make agility < 0, and then in the loop just have .X + agility
If not, you could have a private the_direction variable that you set to 1 or -1 depending on if you press left or right arrow key, and then in the loop use it as so: .X + (agility * the_direction)
B
2
S
1
G
5
Posts: 50
Reputation: 1,500

Post » Wed Dec 19, 2007 7:33 pm

well the agility acts like speed in determining how many times the loop needs to run so it must always be 0 or greater (there should be an event resetting agility, i just haven't added it)

the subevents in the loop determine the direction

so the idea is that with a higher agility, top speed is reached quicker (speed is capped by preventing agility from increasing beyond a certain number) and the loops are there for pixel perfect collision detection (i just haven't added the conditions for collision yet -_-' lol)
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Wed Dec 19, 2007 7:43 pm

How about instead of using a loop you just move the sprite like so:



If agility is 3 then it'd move three pixels, which is the same as moving one pixel three times in a loop. Unless you're using the loop for something else, that is.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Dec 19, 2007 8:02 pm

moving a sprite 3 pixels once and moving a sprite 1 pixel 2 times are 2 different things when it comes to collision detection which is why i do the movements in the loop.

without the loop it would check for collisions every 3 pixels whereas in the loop it would check for collisions at every pixel which is especially important when sprites start covering larger distances in a shorter amount of time
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Thu Dec 20, 2007 12:21 am

why not do a for loop where the maximum number of loops is the agility and in the loop you only move one pixel at a time?
Although i suppose a repeat agilty times would also suffice no?
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Dec 20, 2007 2:12 am

hmmm, the for loop seems to run itself automatically ... =S lol

could you explain it a little further? i'm not really sure how i would go about accomplishing this with a for loop :P
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Fri Dec 21, 2007 2:12 am

okay, i've gotten off my lazy ass and tried something else and it worked so either i don't know how to properly use sub events or i've managed to find a bug :P

this is what i did

- deleted the sub events under the left and right key is down conditions
- made a new event:

+ Key Left arrow is down
+ Sprite2.Value 'agility' Less than 10
OR
+ Key Right arrow is down
+ Sprite2.Value 'agility' Less than 10
: Sprite2: Add 1 to 'agility'

that encompasses the same idea as before but for some reason it works this way and not the other
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests