d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Processing Js Help > Making A Game
Prev12
Add Reply New Topic New Poll
Member
Posts: 16,399
Joined: Mar 28 2009
Gold: 22.69
Dec 6 2016 02:46am
Quote (carteblanche @ Dec 5 2016 11:24pm)
from looking at his numerous topics, very few of his problems has to do with processingjs-specific knowledge. just general coding knowledge is usually sufficient to help the poor guy out. i've just lost interest in his lack of desire to trouble shoot, so i gave up holding his hand.


offhand, i have a few guesses.

where's your code for btn1 that executes when you click it?

Code
var drawRects = function () {
for (var i = 0; i < randomRects.length; i++) {

soo....randomRects.length is always 0, so drawRects doesn't really do much. the only time you increase the length is when you call levelUp. which, by the way, you never call.

i recommend you either add logging or debug to see what code is getting executing "after the player clicks ready". it will answer many of your questions.



I am awful at debugging. I looked up the println method and I'm starting to realize what you mean here. This is what I've narrowed down/changed:

- on line 2 where i declared my levelNumber variable, I left it empty (not set to 0 anymore). So it looks like this: var levelNumber;
- on line 87, in my scene2 function, I call levelUp();

I used the println method to see if anything had changed, which it did. It looks like the levels are increasing now as you can see in the console, every time I hit "click to play," the console increases by 1. (it says 5 because I hit click to play 5 times each time it increased by 1)


Then I chose to see what happens when I println randomRects. Nothing displays so I think it has something to do with a for loop, somewhere.




What do you mean by the bold?

This post was edited by Shakti on Dec 6 2016 02:49am
Member
Posts: 16,399
Joined: Mar 28 2009
Gold: 22.69
Dec 6 2016 03:32am
When I println drawRects, it's saying I have an infinite loop so I reckon the problem does lie within the for loops

Member
Posts: 735
Joined: Jan 23 2007
Gold: 725.94
Dec 6 2016 05:18pm
Quote (Shakti @ Dec 6 2016 03:32am)
When I println drawRects, it's saying I have an infinite loop so I reckon the problem does lie within the for loops


Javascript is printing the value of a function, which is kind of an odd thing to do. I think we should ignore the infinite loop thing for now. That looks like debugging information, not an error message.

Can you change the println() on line 68 to
Code
println(JSON.stringify(randomRects))
? That will tell you what the array looks like. If for some reason the array is empty, no rectangles will be drawn and it would be a good diagnostic since that is the symptom you're having. JSON.stringify() will convert a non-printable type, such as an object or an array, as a printable type in the JSON format. So instead of getting a result like [Object object], you might get {"foo":"bar","baz":"qux"}, which is more helpful.
Member
Posts: 16,399
Joined: Mar 28 2009
Gold: 22.69
Dec 6 2016 05:50pm
Quote (garrettthegreat @ Dec 6 2016 06:18pm)
Javascript is printing the value of a function, which is kind of an odd thing to do. I think we should ignore the infinite loop thing for now. That looks like debugging information, not an error message.

Can you change the println() on line 68 to
Code
println(JSON.stringify(randomRects))
? That will tell you what the array looks like. If for some reason the array is empty, no rectangles will be drawn and it would be a good diagnostic since that is the symptom you're having. JSON.stringify() will convert a non-printable type, such as an object or an array, as a printable type in the JSON format. So instead of getting a result like [Object object], you might get {"foo":"bar","baz":"qux"}, which is more helpful.


println(JSON.stringify(randomRects)); does not do anything :(
Member
Posts: 735
Joined: Jan 23 2007
Gold: 725.94
Dec 6 2016 07:09pm
Edit: need to think some more...

This post was edited by garrettthegreat on Dec 6 2016 07:14pm
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll