• Question
  • getting undefined error in my tower defense game

that means the closest enemy is undefined lmao

ackvonhuelio yeah you damn well need to give me a documentation on this because i have no clue of how this works

    Would you guys mind if I used this as the code basis for a game where it's tower vs tower and they move?
    Sorta like starcraft but also not.
    You play as a person who's goal is to A: Survive
    and B: Keep people from dying.
    You are caught in the crossfire of 2 sides:
    One is 2 incredibly strong fighters, With high move speeds, regen abilities, heavy yet fast melee attacks, and the ability to launch missles which deal splash damage, and lasers cutter attacks, which have to lock on a target first.
    The other is basically just normal people, in far larger numbers. They have several classes:
    Boss: Voxel. Flame thrower, fire capsule (splash damage grenade), Holograms, and can call in RC-probe things to support him. High health.
    Standard soldier: Shotgun, fire capsule. moderate health.
    Arsonist: Can place down a fire turret, can call in probes (these ones shoot fire). Fire capsules.
    Inhibitor: Can place down fire turrets, call in probes, place holograms of both allies and enemies,

      pluto
      not even close
      i didn't implement:
      moneys
      abilities
      winning
      losing
      more than 1 level
      loadout selection

      so theres plenty more for u to do

      -wyi this is an over simplification btw

      pluto
      so basically what i did:

      • replaced all the redundant switch statements with for loops so you don't have to manually plug in every hotbar slot, type of tower, and enemy
        // to remind you how a for loop works:
        for(var i = 0; i < array.length; i++){
        // create variable i and iterate from zero to the length of the array
        console.log(array[i]);
        // print the ith object in the array, since i goes from zero to the length of the array everything in the array is printed
        }
      • added different types of enemies
      • added wave setup variable(creates enemies at specified locations after specified delays with optional messages)
      • added pivot setup variable(creates a bunch of points that will turn enemies when they touch them, causing the enemies to follow a path).
        You can make these pivots visible by changing the variable at the top of the code.
      • fixed enemy+tower size, stats, movement, and shooting.
        enemies/towers/bullets have all the basic attributes, like health and speed, as well as a 'data' attribute which is all of the stats from their type.
        ex: enemy.health gives current health, enemy.data.health gives the max health of all enemies of that type.
      • got rid of all the setIntervals and replaced them with frame-based timing, general advice unless ur making a rythm game or animation or somethin don't use setInterval.

      ackvonhuelio Your stuff is confusing but I'll figure it out well enough with time.

      [unknown] i thought i had a basic knowledge of arrays, but i don't lol

      • -wyi replied to this.

        ackvonhuelio
        What do the variables "i" and "q" on lines 325 - 347 do? I'm kinda just trying to use to code as a way to make an A.I. that shoots other A.I.s of different factions.

        • -wyi replied to this.

          Chat