Simple RPG movement coding

Discussion and feedback on Construct 2

Post » Fri Sep 09, 2011 6:21 pm

Hey guys. I've got almost no past coding experiences so I'm having a difficult time thinking a solution for this.

This is how my character moves (WASD movement)



Now this works pretty well, except for 2 things I can't figure out.

1. When two buttons are pressed at once (ex. W and D) the character flies at a 45 degree angle. I want the player only to be able to press one button as once so I need a way to prevent this.

2. I can't for the life of me let my character stop moving when he hits an object.

Here is the capx if you wanna take a look.

http://www.mediafire.com/?m1dkcz1fznknhdt

Thanks a bunch!

B
14
S
3
G
2
Posts: 37
Reputation: 1,893

Post » Fri Sep 09, 2011 7:00 pm

[QUOTE=Dabbijo] Hey guys. I've got almost no past coding experiences so I'm having a difficult time thinking a solution for this.

2. I can't for the life of me let my character stop moving when he hits an object.

[/QUOTE]

Here you are:   

Bumping into the table from the Right side

go around to the right side of the table with your character, keep a 1-2 meters distance, then press "A" and go toward the table, bump into it.

To add another stop-command for the "S" key:
1. Click on the thin purple space under the event that says "S is DOWN" so the whole event _and_ the thin space below gets orange
2. Right-click that thin orange space
3. Select "Add sub-event"
4. Select your character sprite
5. Click Next
6. Select "Is overlapping another object"
7. Next
8. Click to chose select the sprite "Pokedesk"
9. Done
10. Add Action
11. Select your Main character sprite
12. Instance variables---> Set value Front 0
13. Press and hold CTRL and click on the "Set animation to Front_Stop below", drag it above--> under the new "Set value Front 0" command.
14. continue with the other directions.

Nice graphics, by the way.mercy2011-09-09 19:02:46
B
25
S
5
G
5
Posts: 138
Reputation: 5,638

Post » Fri Sep 09, 2011 8:49 pm

Hi, i saw both of your examples. The problem if you add that condition to all the directions is that once that overlaps the table no key is going to work, so the player get stock.
Adding a simple comparison between both positions will solve that.
Example: http://dl.dropbox.com/u/23880596/rpgtest2.capx
B
16
S
3
G
6
Posts: 19
Reputation: 3,204

Post » Fri Sep 09, 2011 11:03 pm

Whoa guys! Thanks so much.
Love this community, you guys are amazing :)
B
14
S
3
G
2
Posts: 37
Reputation: 1,893

Post » Sat Sep 24, 2011 7:39 am

How about implementing a directional attack - say with a non-shooting weapon?
B
1
G
1
Posts: 4
Reputation: 433


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests