+ 11
Exclusive Chicken Badge!
New code = New Badge to play for đ€đđđ Test your gaming skills in my new code called, "Why did the chicken cross the road?". You can unlock one of my exclusive badges when you complete all 10 levels of the game. This will test your patience and persistence, so be prepared to fail a couple of times. Without any further ado, I give you.. https://code.sololearn.com/WGlDfqT0U0IO/?ref=app#html
13 Respostas
+ 7
This is great! @Gavin
+ 6
Noice
+ 3
I credited you in my work by that function @Jamie âș
+ 2
Thanks again @Nomeh Uchenna Gabriel đ
+ 2
Wow đ that's great @Jamie, you have no idea how much that means to me. đ Now I'm motivated to create more games as well here because I previously felt it's just a waste of time because I'm really aiming for 'Code of the day' but never get it.
I'll just try harder and improve with every code I make. Thanks again for the motivation. đ
+ 2
You're right about that fix @Jamie âș I'll add the change permanently. It was supposed to be just a quick fix so I didn't mind "!=" to stay.
+ 1
Great work. Controls are sticky but I think it's my phone's touch res. One piece of code I'm just curious about:
/** start **/
if(direction=="up"&&chickenY!=0&&chickenY>0)
/** end **/
Since I'm not a web dev, I dunno for sure, but chickenY != 0 && chickenY > 0 could be just chickenY > 0 in my world. I stumbled upon it when tryna mod the controls to work better (on this kak phone).
+ 1
That condition you mentioned was initially:
if(direction=="up"&&chicken!=0)
-but I encountered a problem. When the chicken gets on the logs then it changed how the chicken's Y-axis moves.
-this caused a logical error where the player can move upwards, while on a log, at the edge of the screen at the top and move out of view. Basically going beyond the "Turn around" zone like in most games lol.
-so adding '&&chickenY>0', solved that problem. The chicken can still go beyond the boundaries but not out of view. It will then not be able to move up anymore, only down, left or right.
+ 1
Ah. Okay... I'll have another look at it. Last game I made was +/- 6 years back and my approach was very different and I wasn't working with web. But you've actually inspired me to make and post a game on SL now :)
+ 1
Had another look, you can definitely remove "&&chickenY!=0" from the aforementioned code. It still runs. I suspected it would since you're checking if >0 in the adjacent condition. Web coding adheres to common principles I see.
In my game, I just allowed my player to leave the screen and "corrected" it after the input segment. It's lazy, but at 60fps (I had no idea that was too high) I had to optimise. Speaking of which, mind if I have a dig at your code so it runs better on my mobile? Will WhatsApp you changes on pastebin or something.
+ 1
Yes you can @Jamie, what you edit won't effect the main code. So go ahead and save it as your own in your list of codes then edit it and test out your improvements. âș
+ 1
Thanks Gavin, no need really. Also, changing the != to < and > in the controls fixes the stickiness/responsiveness issues (at least on this phone of mine). It's a generally better practice in games in any case. Eg:
if (direction == "right" && chickenX != 360)
/* becometh */
if (direction == "right" && chickenX < 360)
But anyway, well done.
0
Lol đ So funny @Jamie.. give me a moment to explain..