Exclusive Chicken Badge! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

13th Jul 2017, 9:41 PM
Ghauth Christians
Ghauth Christians - avatar
13 Answers
+ 7
This is great! @Gavin
14th Jul 2017, 2:18 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 6
Noice
14th Jul 2017, 4:55 PM
Ehtesham Ali
Ehtesham Ali - avatar
+ 3
I credited you in my work by that function @Jamie ☺
18th Jul 2017, 2:20 PM
Ghauth Christians
Ghauth Christians - avatar
+ 2
Thanks again @Nomeh Uchenna Gabriel 😊
14th Jul 2017, 7:54 AM
Ghauth Christians
Ghauth Christians - avatar
+ 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. 😊
15th Jul 2017, 11:40 PM
Ghauth Christians
Ghauth Christians - avatar
+ 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.
18th Jul 2017, 2:17 PM
Ghauth Christians
Ghauth Christians - avatar
+ 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).
15th Jul 2017, 11:14 PM
Jamie
Jamie - avatar
+ 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.
15th Jul 2017, 11:25 PM
Ghauth Christians
Ghauth Christians - avatar
+ 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 :)
15th Jul 2017, 11:36 PM
Jamie
Jamie - avatar
+ 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.
18th Jul 2017, 2:11 PM
Jamie
Jamie - avatar
+ 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. ☺
18th Jul 2017, 2:14 PM
Ghauth Christians
Ghauth Christians - avatar
+ 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.
18th Jul 2017, 3:25 PM
Jamie
Jamie - avatar
0
Lol 😂 So funny @Jamie.. give me a moment to explain..
15th Jul 2017, 11:16 PM
Ghauth Christians
Ghauth Christians - avatar