Game Maker Tutorial: Snake Game - playproduction.de

Game Maker Tutorial: Snake Game

Veralos
Views: 31760
Like: 246
A tutorial on how to make a “Snake” game in Game Maker. If you don’t know what Snake is, it’s an old game where you play as a snake. You must collect points while avoiding your tail, which grows longer depending on the score.

This tutorial was requested by halohunter7676.

I would like to have some feedback on this tutorial. Was it too simple or too complex? Did it explain enough or did it explain too much? Should I do tutorials in drag and drop or GML? I want to know what people think, so I can hopefully improve if I make another one in the future.

Wow, it’s been a long time since I last uploaded something…

99 Comments

  1. hey!, I have a question, why do I keep getting this error : Error in Object obj_head, Event Collision obj_tail, Action 1 at Line 1, Position 1: Unknown function or script: highscore_show ?
    Thanks in advance 🙂

  2. Could somebody help me with this error? please

    FATAL ERROR in
    action number 1
    of  Step Eventobj_food
    for object obj_head:

    Push :: Execution Error – Variable Get -1.obj_control(100005, -1)
     at gml_Object_obj_head_CollisionEvent_1 (line 8) – obj_control.alarm[0]=30*global.spd

  3. Thank you so much for this, I thought the video was a bit quick for super beginners like me. but I was able to keep up 😀

    I ran into an issue with highscore_show
    it said it was an invalid command…

  4. I can play the game but there isnt spawned a tail behind the head. Any ideas to fix it?

  5. The snake wont automatically start moving 

  6. Good tutorial but when i go up it doesnt go to the bottom but it working for every other side, can you help?

  7. BasE_Dope / Trickshot recruiter / Callofdeath1997 says:

    i can't do the last part where i have to fill this in :

    draw_set_halign(fa_center)
    if alarm[0]>0
    draw_text(room_width/3,0,''Special Time: ''+string(ceil(alarm[0]/30)))
    draw_text(room_width/3*2,0,''Score: ''+string(global.points))

    it says in line 3 position 28 there have to be , or ) 
    but not only there on multipuple spots i have tried it but that didnt work,
    Can you help me??

  8. —This is a message sent in reply to Veer Barmi's comments. I thought I'd also add it here so anyone else can see it—

    "how do i get the food to stay in one spot?"
    "and when you collect it, it will add only one to you and then vanish?"

    Remove this from the control object's "create" event:

    with (food) {
     do
     move_random(32, 32)
     until
     place_empty(32, 32)
    }

    Remove the same segment from the snake object's "collision with food object" event and replace it with this:

    with (other) instance_destroy()

    Presumably you want to be able to place where the food starts. To do this, remove the following in the control object's "create" event:

    food=instance_create(0,0,obj_food)

    You can then place the food wherever you want using the room editor.

    In future please enables replies on your comments when asking a question so I can respond to you more easily.

  9. hey! how would i use this to rotate the body sprite?(having trouble getting the sprites to turn only after you turn) and also how would i add another part of the snake?(ie a actual tail)

  10. —This message is in reply to Kalenna Ree's comment. In future please enable replies on your comment when asking a question—

    "hey! how would i use this to rotate the body sprite?(having trouble getting the sprites to turn only after you turn) and also how would i add another part of the snake?(ie a actual tail)"

    To get the tail parts to rotate, first give the tail sprite a rotation animation similar to the head sprite (four frames, the first pointing right and the rest moved 90 degrees counter-clockwise each time). Then, give the tail object a Create event with this code:

    image_speed = 0;

    Add this to the end of the head object's Alarm 0 event:

    tail.image_index = image_index;

    This will set the created tail piece's direction to the head's current direction.

    I don't understand the second part of your comment. Could you please clarify what you meant?

  11. Excellent video!!! Thanks so much for uploading!

  12. Thanks for the tutorial i love it. But i have a problem. When i click the "Run the game" button it wont open. At first i comes the CompileForm window, and then a window who stands in it: Made wirh GameMaker studio. But then nothing happens. What should i do? Sorry for my bad Englisch.

  13. When i press play on 4:25 the snake dont move. Help me please!!!

  14. _________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Create Event
    for object obj_head:

    Push :: Execution Error – Variable Get 100000.x32(100003, -2147483648)
     at gml_Object_obj_head_CreateEvent_1 (line 7) – tail=instance_create(x32*n,y,obj_tail)
    ############################################################################################

  15. Hi! so i followed your tutorial, however i want the snake game to be in an enclosed area (surrounded by walls that are solid) in the lowerhalf of my room, and have a sort of logo at the top with the score etc. however, i cant stop the food from spawning outside the walls of the enclosed area. is there a way to make the food spawn randomly in a certain area and not outside that certain area?

  16. SICK video had a few errors but it turned out i had mispelt control haha works perfectly for me!!

  17. please help!!

    ERROR in
    action number 1
    of Alarm Event for alarm 0
    for object obj_head:

    Error in code at line 2:
    tail.alarm[0]=global.spd*(5+floor(global.points/2))

    at position 42: Unknown variable points

  18. i have a border on the right and the lower wall, where i cant be with my snake, but food spawn there. plz halp

  19. When the snake hits the yellow food nothing happends. What did I wrong?

  20. Hey bud, nice tut! If I might ask, do you happen to know what the "Magic Number" is for have the tail length go up by 1 for every point you get?

  21. When i launch the game i can see only gamemaker studio write on the screen vut nothing launches :/

  22. I have the exact sale thing but it won't work PLEASE HELP MAN

  23. how would you add an object that on collision, would add like 5 tails instantly to your tail

  24. okay, so I'm doing this for school, right. well, I did everything up until the first test of the game correctly. I checked the codes and everything three times even. but when I tested it it only popped up with the even Made with Game Maker Studios and gets stuck. Does that mean I did something wrong somewhere even after checking all that or Game Maker is just screwing up and I have to start over? also, how could I make my snake have like a more realistic tail (y'know, pointed instead of square) cause if I do it this way with the pointed tail the snake will look odd.

  25. I did something wrong?

    FATAL ERROR in
    action number 1
    of Draw Event
    for object obj_hud:

    global variable points(100001, -2147483648) not set before reading it.
    at gml_Object_obj_hud_DrawEvent_1 (line 4) – draw_text(room_width/3*2,0,"Score: "+string(global.points))

  26. You should make a new video about this, seeing how it got tons of views, and please write comments on the code if you do c: I had to do so in my own, because I couldn't tell what was happening most of the time :/ But awesome video dude!

  27. Coders help! Line 9 is giving me a compile error. I have no idea why, and I made sure it's the same code as in the video. I'm still new to GML so if i were more experienced I'd probably understand what happened, but I think that the compiler is generating too many tails :/ PLZ HALP

    global.spd = 5
    global.canwarp = true //If true, the snake will warp through walls.
    canturn = false
    image_speed = 0
    alarm[0] = global.spd

    //Generate a short tail behind the snake when the game starts.
    repeat(5) {
    tail = instance_create(x-32*n,y,obj_tail)
    tail.alarm[0] = global.spd*(6-n)
    n-=1
    }

  28. Hi,everything else works with your project execpt my snake keeps moving right and then it repeats and repeats:I also cant control it.Please help.

  29. Highscore_show appears to have disappeared in the GML's functions ?

  30. my game fails to load. compiler states "entering main loop" but nothing happens afterwards

  31. when the snake hits the food the head bounces the opposite direction and hits the tail? 🙁

  32. my body follows the head but it leaves space and if I turn the snake spaces increase more

  33. Hey! Nice video but I have a problem, on the first time you test the game (when you have only the snake), the compile would never finish, it just stayed at the quote, Entering main loop. If you could help me on this I would be very grateful!

  34. when I hit the obj_food it shows up the highscore table?

  35. _________________________________________
    FATAL ERROR in
    action number 1
    of Draw Event
    for object obj_control:

    COMPILATION ERROR in code action
    Error in code at line 3:
    draw_text (room_width/3,0"Special Time: "+string (ceil(alarm[0]/30)))
    ^
    at position 27: Symbol , or ) expected.

  36. _________________________________________
    FATAL ERROR in
    action number 1
    of Alarm Event for alarm 0
    for object object0:

    COMPILATION ERROR in code action
    Error in code at line 1:
    tail-instance_create(x,y,sprite1)
    ^
    at position 5: Assignment operator expected.

  37. FATAL ERROR in
    action number 1
    of Create Event
    for object obj_head:

    COMPILATION ERROR in code action
    Error in code at line 4:
    alarm(0)=global.spd
    ^
    at position 2: Unknown function or script: alarm

  38. It was a great tutorial however, I would like the snake to look more real and for you to slow down a bit otherwise it was a very good tutorial…

  39. i tried this but when i run it it creates more parts every time i move insted of when i eat a food object

Leave a Reply

Your email address will not be published.