🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

I'm making a 2d game, and am having a problem with one line of code.

Started by
15 comments, last by another2dgamedev 3 years, 7 months ago

@Endurion Here is the code: https://editor.p5js.org/LttntLark/sketches/IauCPtvxN

Advertisement

It says script error, only because i needed to put all the files into this website. Line 32 of player.js has the broken line grayed out.

A weird environment. Anyhow, the problem is, that d ends up being “NaN”.

keyDown.A and keyDown.D are both undefined.

Try outputing values with console.log( variablename );

That shows even in that environment on the bottom left side.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

@Endurion How do i do that exactly? im sorry, i just started with javascript, and the code is all from a tutorial

Ah, didn't see I can look at all the other files as well. Anyhow, settings this inside player.js works for me:

var d = 0;
if (keyDown.D)
{
  d = 1;
}
if ( keyDown.A )
{
  d = -1;
}

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

@Endurion Thank you!

@Endurion Thanks to your help, here is the finished rough-draft of my game:
https://editor.p5js.org/LttntLark/present/IauCPtvxN

This topic is closed to new replies.

Advertisement