My take on Snake

Post gaming related scripts
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

My take on Snake

24 Aug 2017, 17:34

I got bored and decided to write a version of Snake.
Hope someone finds it fun or interesting.
I am sorry but this code requires Windows 7+ and IE 11+ to run properly.


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by maestrith on 28 Aug 2017, 21:53, edited 14 times in total.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
Masonjar13
Posts: 1112
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: My take on Snake

24 Aug 2017, 18:06

Nice maestrith! Because I'm the sadistic type (ever played Velocibox at 3x speed?), I added a speed modifier option. Feel free to clean it up, but seems to work well enough.

Regular (2 start length): 69 (got bored)
Speed@50 (2 start length): 45
Edit 2: Speed@10 (100): 16

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Edit: changed the modifier to 1-10 (multiplied by 10).
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

25 Aug 2017, 07:44

I'll possibly get to actually making some more options, but I am working on improving performance :) It starts to slow down around 200 or so body segments.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
Delta Pythagorean
Posts: 306
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Re: My take on Snake

25 Aug 2017, 08:30

*Cracks knuckles* Alright, let's see how many times I have to press space this time...
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

25 Aug 2017, 09:58

Added:
-Random Colors
-Zen Mode (no way to lose)
-Bumped up the start from 1-100 to 1-500 (it starts to slow a bit at about 400 or so)
-Score, Snake Length, and Mode displayed in the Title

I'll add more options later. I have a doctors appointment to go to.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
Masonjar13
Posts: 1112
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: My take on Snake

25 Aug 2017, 18:52

Oh jeez.. The random colors makes it nearly impossible to tell where the head is. Can the head be a more distinct color, or have the random colors as a switch? The title update was a great idea!

Edit: testing the limits, about 1011 length starts stuttering for me (at 9 speed, which should be 10ms delay, if you didn't change it). Around 1600-2000 it's about as slow as starting speed, and uses a whopping 50mb of memory and 15% CPU. At 4300, each body segment takes around 500ms to add. 5000, working set peaked at 103MB, CPU peak of about 16.8%. I realize this isn't technically useful information, I just like breaking things. ;)
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

25 Aug 2017, 22:32

LOL! yea, I have some settings in the works I just had an appointment and then I fell asleep when I got home. I just woke up and I will work on some things.

I know it is a bit of a resource hog but it works a lot better than the original version. At around 80-100 it would start to flicker a lot and just look terrible.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

26 Aug 2017, 06:26

Update:
-Settings Page: Press Escape to Start the game and show Settings
-Colors: Edit the colors of the head of the snake and the body
-Zoom: Not what you think
To Do:
-Setup custom keys for directions and Settings
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
Masonjar13
Posts: 1112
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: My take on Snake

26 Aug 2017, 17:58

Hm, feels like there's a problem with the colors.. My assumption was that, by setting the two colors for the body, they would alternate only those colors. It seems to often disrespect the colors and add random ones in anyway. They're also not alternating, but seemingly randomized. I didn't look too terribly hard, but I didn't see anything in the code explicitly that would do that. Or is it meant to be within the range of the two colors? Because that seems accurate then.
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

26 Aug 2017, 18:02

It is a range between the two colors
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
Masonjar13
Posts: 1112
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: My take on Snake

26 Aug 2017, 18:13

Ah, yeah that makes a lot more sense. Also noticed that the head, being the first created, has the lowest z-index. Only applies to Zen mode: when you go back over your own body, your head appears underneath the other segments, making it non-visible. Not sure how you could alter that, but it would help tremendously to have the head always on top.
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

26 Aug 2017, 18:17

I'll see if I can fix it.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

26 Aug 2017, 18:25

Changed: Suggested by Masonjar13
-Changed the Z order of the head to be on top.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

27 Aug 2017, 14:52

Changed:
-Added: Change the hotkeys
-Re-Wrote a good portion of the code
-Changed the Snake Length to an HTML control
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
Helgef
Posts: 2420
Joined: 17 Jul 2016, 01:02
Contact:

Re: My take on Snake

27 Aug 2017, 15:17

Hello!
I tried it earlier, very nice, a classic! Thanks for sharing. :clap: :thumbup:

The latest version gives me an error though.

Code: [Select all] [Expand] [Download] (Untitled.txt)GeSHi © Codebox Plus


Cheers.

Edit:
maestrith wrote:oops. Fixed.

:thumbup:
The read head is a nice improvement. I'm not very good though :lol:
Last edited by Helgef on 27 Aug 2017, 15:34, edited 1 time in total.
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

27 Aug 2017, 15:26

oops. Fixed.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

27 Aug 2017, 15:29

Helgef wrote:Hello!
I tried it earlier, very nice, a classic! Thanks for sharing. :clap: :thumbup:
Cheers.

Thanks :)
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

28 Aug 2017, 09:07

Added:
-Board Size: Select and it will Reload (Will make this not reload in a future release)
-Snake Size
-Shift+Escape also exits the game
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32
User avatar
SpeedMaster
Posts: 93
Joined: 12 Nov 2016, 16:09

Re: My take on Snake

28 Aug 2017, 12:54

Hello,
Very nice ! :thumbup:
but... Only the modified by Masonjar13 old version is working for me :cry:

Error: 0x80020006 - Nom inconnu.
Specifically: CreateElementNS
---> 103: defs := this.Doc.CreateElementNS("http://www.w3.org/2000/svg","defs")
User avatar
maestrith
Posts: 684
Joined: 16 Oct 2013, 13:52

Re: My take on Snake

28 Aug 2017, 14:32

SpeedMaster wrote:Hello,
Very nice ! :thumbup:
but... Only the modified by Masonjar13 old version is working for me :cry:

Error: 0x80020006 - Nom inconnu.
Specifically: CreateElementNS
---> 103: defs := this.Doc.CreateElementNS("http://www.w3.org/2000/svg","defs")

I am using SVG which requires IE 11+. Divs start to flicker badly, at least on my system, at around 100 or so and the SVG do not flicker even when my PC starts to slow down at 500 or so. https://support.microsoft.com/en-us/help/17621/internet-explorer-downloads but Windows 7 is the minimum OS that will run it.

I tried the older version using IE 10 and below and the body segments were rectangular not square :( It just won't work properly below 11.
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests