Sequential Grid-Based Movement

Get help using Construct 2

Post » Tue Sep 17, 2013 8:48 am

@R0J0hound

Thanks for the more detailed explanation.

I've gotten the direction and distance working, but it's building the backwards list that isn't working for me.



My dirs = "" at all times, and I'm not sure why.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Tue Sep 17, 2013 9:57 pm

My issue lies in the backtracking, as I'm not sure what exactly the round(cos(90)) stuff is doing. Could you elaborate a bit more on that part?

@R0J0hound
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Thu Sep 19, 2013 7:13 am

I've done some more testing with the debugger. The problem isn't the backtracking - that part should be working. However, for some odd reason my string isn't being updated properly.



My dirs variable is a local static text.

The PathToDestination function is only called once due to a 'trigger once' clause. Any idea why my string is always empty?

BoardGame.capxExcal2013-09-19 07:15:03
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Thu Sep 19, 2013 8:56 am

Here is a quick debug 101 for problems like this, or how I would approach finding out what is wrong.

First, add log messages. This way you can easily see what is happening during runtime (the debugger has tool that can do similar stuff, but I am a bit old school). These log messages are displayed in browsers log and tell you what exactly is going on in your variables.



Here is the output:



This suggests your problem is related to the second comparison in the event.

Another thing: It seems you use separate functions (copy pasted?) for AI and player movement. It's generally bad practice to copy paste same code to two places, and you should look for a way to use same functions for AI and player programs if they do the same thing.

And also; commenting your events is very, very useful when you come back to your project after two week vacation or show it off to people in the forums :P. I generally write short comment above every function about what it should do, what do the input variables mean and describe any return variables. At least for me this is a must, that way I don't have to spend anytime wondering what these events do :)

Hope this helps, your game keeps getting better every time I see it!
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Thu Sep 19, 2013 9:00 am

[QUOTE=vee41] Here is a quick debug 101 for problems like this, or how I would approach finding out what is wrong.

First, add log messages. This way you can easily see what is happening during runtime (the debugger has tool that can do similar stuff, but I am a bit old school). These log messages are displayed in browsers log and tell you what exactly is going on in your variables.


[/QUOTE]

I assume you mean debugger breakpoints? I have no idea how to set those, as I assumed they would be under the System object but couldn't find any breakpoint events :(

[QUOTE]
Here is the output:



This suggests your problem is related to the second comparison in the event.

Another thing: It seems you use separate functions (copy pasted?) for AI and player movement. It's generally bad practice to copy paste same code to two places, and you should look for a way to use same functions for AI and player programs if they do the same thing.[/QUOTE]

Yes, I use separate functions for AI and player movement. The main reasoning is that the player movement function checks for different things than the computer movement one. The computer movement function also has more parameters due to the AI needing more instructions for movement and targeting, etc.

UPDATE: No idea why there is an error with the function call. Both functions appear to be working perfectly for highlighting movement.

[QUOTE]
And also; commenting your events is very, very useful when you come back to your project after two week vacation or show it off to people in the forums :P. I generally write short comment above every function about what it should do, what do the input variables mean and describe any return variables. At least for me this is a must, that way I don't have to spend anytime wondering what these events do :)
[/QUOTE]

Almost everything in the project is commented. Some of the newer stuff that I'm trying to debug isn't, but I usually add comments once things are fixed up.Excal2013-09-19 09:04:56
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Thu Sep 19, 2013 9:00 am

@vee41
I can't bookmark your post (wish I could), so just commenting so I can search it later.
Brilliant approach to debugging. Learning so much from this project.

@Excal
Browser - log - messages (edit) see vee41 below
Hit F12 in chrome ;)DUTOIT2013-09-19 09:08:47
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,698

Post » Thu Sep 19, 2013 9:07 am

[QUOTE=Excal]

I assume you mean debugger breakpoints? I have no idea how to set those, as I assumed they would be under the System object but couldn't find any breakpoint events :(
[/QUOTE]

Right click on event block and you can toggle breakpoints. I still prefer Browser -> log messages though :)

The error in function call is because no events are ran (comparisons prevent that). It's normal, no reason to get worried :)vee412013-09-19 09:08:22
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Thu Sep 19, 2013 9:08 am

The functions that trigger a console warning are the player highlighting function, computer highlighting function, and building a direction list.

One thing about all three functions - they are recursive and call themselves until 'stop conditions' are met. However, they appear to be working perfectly, even if Chrome gives me a warning.

As to the actual issue of the local static text 'dirs' always equaling "", I think I'm going to just make it global and see if the scope change solves the issue.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Thu Sep 19, 2013 9:10 am

[QUOTE=Excal] The functions that trigger a console warning are the player highlighting function, computer highlighting function, and building a direction list.

One thing about all three functions - they are recursive and call themselves until 'stop conditions' are met. However, they appear to be working perfectly, even if Chrome gives me a warning.

As to the actual issue of the local static text 'dirs' always equaling "", I think I'm going to just make it global and see if the scope change solves the issue.[/QUOTE]

Like I demonstrated in the screenshots, the scope is not the issue. It is the comparison. And those log errors with functions are normal, they appear as no events are ran because comparisons at the start are false.
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Thu Sep 19, 2013 9:11 am

The comparison?

The BoardSpaces condition?Excal2013-09-19 09:12:17
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], pokka, robopunch and 5 guests