Game Maker Studio 2: Tower Defense Game 2/3

Поділитися
Вставка
  • Опубліковано 8 вер 2024

КОМЕНТАРІ • 70

  • @TeenyEevee
    @TeenyEevee 10 місяців тому +2

    6 years ago and it still works. nice!

  • @stormmerm4776
    @stormmerm4776 7 років тому +5

    A solution for spawning turrets that I find a bit more elegant is having a single slot object (clickable) which can be used for all turrets (using a ds_map for each tower's data). That slot object, once clicked and the button is hold, can draw the turret's sprite at the mouse coordinates. This way you have only one of each turret object and a slot, instead of three objects per turret.

  • @ryanblaney3937
    @ryanblaney3937 5 років тому +2

    For those of you using physics, use this in the alarm[0] event (projSpeed is substituted for 10):
    if (instance_exists(objectToShoot)) {
    var bullet = instance_create_depth(x, y, -9, oBullet);

    var dir = point_direction(x, y, objectToShoot.x, objectToShoot.y);

    bullet.phy_speed_x = lengthdir_x(projSpd, dir);
    bullet.phy_speed_y = lengthdir_y(projSpd, dir);
    bullet.speed = projSpd;

    alarm[0] = fire_rate;
    } else {
    shooting = false;
    }

  • @sunstreak_games
    @sunstreak_games 7 років тому +14

    Here's a recommendation for the circle and line things. Have them only appear when the mouse is hovering over the circle so when you're at later rounds your screen isn't full of circles and lines. Also, is there going to be stuff on upgrade? Or will we be figuring it out on our own?

    • @RealTutsGML
      @RealTutsGML  7 років тому +3

      Great idea, part 3 doesn't include upgrades.

    • @Cl0v3rComics
      @Cl0v3rComics 5 років тому +8

      @@RealTutsGML So will there be like a bonus episode for that or no? I understand if you cant but plz make an episode of that.

  • @jasonsingell6998
    @jasonsingell6998 2 роки тому +1

    I absolutely love your tutorial!!! Just finished the first two videos and looking forward to the third video! Like SB 64, I would love it if you made a tutorial on upgrading towers. I assume if you wanted to change the sprite upon upgrading it would be something like using the destroy code on the existing tower and a build code for the new one.
    I have a bad habit of making things my own while following tutorials, lol. So, all three of my towers already act differently. My first tower shoots the nearest, the second one shoots the furthest (but won't shoot any of the ones in range if the furthest one is not in range...can't seem to fix that), and my third tower does both simultaneously. I also have used images for my sprites and my background layer to create a Sponge Bob theme for my kids...LOL So, my enemies are Plankton, my towers are Sponge Bob, Krabs, and Squidward (playing his flute). Obviously, Squidward playing his flute will be the strongest and harms the nearest and furthest simultaneously (I wanted him to hurt all towers in range but couldn't figure that out yet).
    I also put in some code to prevent players from placing towers in the attack range of other towers and gave my towers each a different range. This way, towers can't be placed on each other or grouped really close so players have to use a bit more strategy.
    Please do consider creating more tutorials on this game type because it has been uber helpful and I can't wait to learn more!

  • @slipken
    @slipken 3 роки тому

    If you're like me and did not what the circle showing but wanted to display if the player clicks on the tower?. Go into you tower3D or your TowerDrag group, have a create event that has the range stored then create a draw event ; "draw_circle(x,y,range,true)" ; now when you click on the tower it will show the range of the tower before you can place it down. Enjoy!

  • @diddykong3220
    @diddykong3220 7 років тому

    Thank you for all your Tutorials, they really helped me!
    Keep it up👍🏻

    • @RealTutsGML
      @RealTutsGML  7 років тому

      Thanks! I'm really glad you're enjoying them.

  • @Ms_Vylet
    @Ms_Vylet 3 роки тому +1

    I need some help, I have the code itself exactly the same as yours, yet with the firerate, it fully automatically fires a bunch of bullets at a time

  • @ns_ml137
    @ns_ml137 7 років тому +3

    when is part 3 coming out?

  • @draxior5555
    @draxior5555 6 років тому

    thx it helped me for my rts i did not know how to place the turret

  • @alexandregarcia3331
    @alexandregarcia3331 2 місяці тому

    my tower keeps shooting even when the enemy is out of it's range, what could it be?

  • @Arylice
    @Arylice 6 років тому +3

    the "bullet.direction" doesn't seem to apply on the bullets.... 15:00
    ...
    ooooooooooh... ".direction" is not the same thing as "image_angle"... Nevermind, Sorry! Great tuto!

  • @hunteranubis
    @hunteranubis 3 роки тому +1

    Ive got tiny problem with this. I create a tower (already placed down on map for purpose of testing but when enemies aprouch the tower and enter its radious they only fire at enemies in certain direction. Like fire only in the upper part of the circle

    • @RealTutsGML
      @RealTutsGML  3 роки тому

      Interesting problem, the only thing I can think of without looking at the code is to check the origin of your sprites and be sure it matches the tutorial.

    • @PabloSantos-ee1fj
      @PabloSantos-ee1fj 11 місяців тому

      Use this code
      if (instance_exists(objectToShoot)){
      // Verifica se o temporizador de disparo está ativo
      if (!alarm[0]) {
      // Criando balas
      var bullet = instance_create_depth(x, y, -9, oBullet);

      // Configurando a bala
      bullet.speed = 10;
      bullet.direction = point_direction(x, y, objectToShoot.x, objectToShoot.y);

      // Define o temporizador de disparo para a taxa de disparo desejada
      alarm[0] = fire_rate;
      }
      } else {
      shooting = false;
      }

  • @Bluecone598
    @Bluecone598 5 років тому

    the *Left_Pressed* one it supposed to *Left_Release* and the *Left_Pressed*
    just the same as the *step*

  • @marlonlernmark
    @marlonlernmark 5 років тому +2

    I tried this but it doesn't work! When I click the tower in the bottom corner nothing happens! Help!

    • @Zyrex216
      @Zyrex216 5 років тому

      same

    • @natsuoishido1336
      @natsuoishido1336 5 років тому

      @@Zyrex216 Same, does anyone find something about it guys ? i would love to know !

    • @natsuoishido1336
      @natsuoishido1336 5 років тому +1

      ​@@Zyrex216 In my case i have fail the code on the oTower1C and write coins instead of cost in the 3 line :p

    • @natsuoishido1336
      @natsuoishido1336 5 років тому

      now it works perfectly !

    • @Zyrex216
      @Zyrex216 5 років тому

      Dan Botton ok was going to say check events ans objects are in the right place

  • @mrmemefrog6172
    @mrmemefrog6172 3 місяці тому

    my duplicated turrets arent changing their form?? i copied everything

  • @destroyergaming5205
    @destroyergaming5205 4 роки тому

    it will not allow me to place the towers down and they also don't shoot.

  • @djscarix9994
    @djscarix9994 2 роки тому

    8:26 i can click on the towers but not place the tower can someone help me pleaz.

  • @senjecko
    @senjecko 7 років тому +1

    wow the differences in how the logic changes between 1.4 and 2 are mind boggolingly illogical

  • @allensantos4701
    @allensantos4701 6 років тому

    Hi! I can't seem to find my error. not literally error but I can't put towers smoothly sometimes it create one sometimes not. we have the same code. can you/someone help me?

  • @tomaswhelan2473
    @tomaswhelan2473 5 років тому

    i keep getting this FAILED: Run Program Complete in output box

  • @spprouttzx
    @spprouttzx 2 місяці тому

    where part 3?

  • @Fos4ity
    @Fos4ity Рік тому

    Does anyone know how make tower attack at different enemies (different object)

    • @Mr.BrainMatterOfficial
      @Mr.BrainMatterOfficial Рік тому

      var en = instance_nearest(x,y,oWhatever) or instance_nearest(x,y,oExample) rinse and repeat per enemy

  • @basburger6367
    @basburger6367 3 роки тому

    Hey! I have a little problem with the oTower1C object. I have the exact same code as shown in the video, but whenever I click on the object in the game nothing happens. Would anyone know how to fix this? maybe it's because of the new update that this doesn't work anymore? any help would be appreciated :)

    • @distantsails
      @distantsails 2 роки тому +1

      Change the Left Pressed to Left Release, and the Left Release to Left Pressed :-)

  • @pierre-louisgaucher3537
    @pierre-louisgaucher3537 4 роки тому

    Hello I don't know if I'll get a response here because this video is online since 2017 but I have a problem that I'm currently not able to fix : I used the same code than you but my bullets aren't going on ennemies : they appears on my turrets, the line follows the ennemies but bullets aren't going on ennemies ? what can I do ?

    • @RealTutsGML
      @RealTutsGML  4 роки тому

      Set the bullet speed in the create event to any number you'd like. i.e. speed = 10;
      Hope that helps good luck!

    • @pierre-louisgaucher3537
      @pierre-louisgaucher3537 4 роки тому

      @@RealTutsGML Hello ! I just rewatch and restart all the tuto and it works perfectly

    • @basicperson4245
      @basicperson4245 3 роки тому

      @@RealTutsGML Hello, im getting this error, on oTower1,
      ___________________________________________
      ############################################################################################
      ERROR in
      action number 1
      of Draw Event
      for object oTower1:
      local variable (-1610512709, -2147483648) not set before reading it.
      at gml_Object_oTower1_Draw_0 (line 5) - if(en != noone){
      ############################################################################################
      gml_Object_oTower1_Draw_0 (line 5)

  • @ChaiKirbs
    @ChaiKirbs 6 років тому +1

    your website seems to be down, just so you know

  • @user-xu8go4vp3t
    @user-xu8go4vp3t 4 роки тому

    My bullets dont fly to enemy. They are creating in tower and stay here. Where was i can make misstake?

    • @user-xu8go4vp3t
      @user-xu8go4vp3t 4 роки тому

      my code alarm [0] :

    • @user-xu8go4vp3t
      @user-xu8go4vp3t 4 роки тому

      if(instance_exists(objectToShoot)){
      var bullet = instance_create_depth(x,y,-9,obj_bullet);
      bullet.speed = 10;
      bullet.direction = point_direction(x,y,objectToShoot.x,objectToShoot.y);
      alarm[0] = fire_rate;
      }else{
      shooting = false;
      }

    • @user-xu8go4vp3t
      @user-xu8go4vp3t 4 роки тому +1

      I has found my misstake. I forgot about physics. it was eneble in room

  • @Ash-lm1dw
    @Ash-lm1dw 4 роки тому

    "Amwriter free" i use to mod rusted warfare and do the coding but coding is hard to remember so i have to copy a bit

  • @Skydrake.
    @Skydrake. 5 років тому

    Actually, is recommended that you lose coins after you place tower because if you press and then doesn't want to use, the money will be not there, pls fix that.

  • @lunasoldev
    @lunasoldev 3 роки тому

    My towers shoot once and then they just stop... ples help

    • @alexanderpao7852
      @alexanderpao7852 3 роки тому

      did you remember to set alarm 0 to equal fire rate in the if statement?

  • @vanessamanimtim3651
    @vanessamanimtim3651 6 років тому

    @RealTutsGML icant put towers can you help me?

    • @kouzaris579
      @kouzaris579 4 роки тому

      Late reply, but drag your instance layer above the tile layer.

  • @jakerbaker3386
    @jakerbaker3386 2 роки тому

    i dont think this code works anymore i tried and tried and couldn't get it to work.

  • @theycallmepapi6804
    @theycallmepapi6804 3 роки тому

    mad man

  • @ns_ml137
    @ns_ml137 7 років тому +1

    7:36

  • @ns_ml137
    @ns_ml137 7 років тому +1

    15:25

  • @quaking906
    @quaking906 7 років тому

    i cant drag the tower

    • @awaite1
      @awaite1 7 років тому

      same, all my code is identical, not sure what's going on

    • @awaite1
      @awaite1 7 років тому +1

      I needed to swap the left click events on both the clickable and dragged,
      so change Pressed Released on both oTower1C and oTower1D

    • @hrcornish
      @hrcornish 2 роки тому

      @@awaite1 This helped me 4 years later so thanks!

  • @owenhobbs1758
    @owenhobbs1758 7 років тому

    hi

  • @Mr.BrainMatterOfficial
    @Mr.BrainMatterOfficial Рік тому

    Uhh.. line 7 of the draw event for the towers just randomly started breaking
    This is the code
    draw_self();
    if(mouseOver(x,y,sprite_width,sprite_height))
    draw_circle(x,y,range,true);
    var en = instance_nearest(x,y,oRed) or instance_nearest(x,y,oSpd) or instance_nearest(x,y,oBig)
    if(en != noone){
    if(point_distance(x,y,en.x,en.y)

  • @ns_ml137
    @ns_ml137 7 років тому +1

    3:19