Discord
Login
Community
DARK THEME

Currently Debuging can't find issue to problem

I'm trying to fix this issue with my code here, the enemies aren't appearing is there a typo or something?

  enship_sprites = ["ufo1","ufo2","ufoo","hambrgrufoo"]
  ships = []
end

createEnship =  function()
  local enship = object 
    x = 190
    active = true
end
enship.sprite = choose(enships_sprites)
enship.size = randRange (20,28)
enship.y = randRange(-100,100)
enship.speed = randRange(0.5,1)
ships.push(enship)
end

drawEnship = function()
  screen.setDrawScale(-1,1)
  for e in enship
    screen.drawSprite(e.sprite, e.x, e.y, e.size, e.size)
  end
  screen.setDrawScale(1,1)
end

updateEnship = function()
  local temp = []
  for ships in enships
    enship.x -= enship.speed
    if  enship.x < -240 then
       enship.active = false
    end
     for blast in blasts
       if distance(blast.x, blast.y, 
         enship.x, enship.y) < enship.size/3 then
         enemy.active = false
         blast.active = false
         createExplosion(enship.x, enship.y, 20)
         end
     end
       for blast1 in blasts1
       if distance(blast1.x, blast1.y, 
         enship.x, enship.y) < enship.size/3 then
         enemy.active = false
         blast1.active = false
         createExplosion(enship.x, enship.y, 20)
         end
       end
       
      if enship.active then 
        temp.push(enship)
      end
  end
    enship = temp
    if random.next() < 0.1 then
      createEnship()
    end
    end
//And then this
```init = function()
  initBlast1()
  initBlast()
initPlayer1()
initEnship()
end


update = function()
  moveBlast1()
  fireBlast1()
  moveBlast()
  fireBlast()
  updatePlayer1()
  createEnship()
  updateEnship()
end


draw = function()
 drawPlayer1()
    drawBlast()
    drawBlast1()
    drawEnship()
  end

  https://microstudio.io/i/P1X3L_2012/spacequestr/

I am not so sure, however I think the "for e in enship screen.drawSprite(e.sprite, e.x, e.y, e.size, e.size) end" Is missing it up I think

Here it is:

 enship_sprites = ["ufo1","ufo2","ufoo","hambrgrufoo"]
  ships = []
end

createEnship =  function()
  local enship = object 
    x = 190
    active = true
end
enship.sprite = choose(enships_sprites)
enship.size = randRange (20,28)
enship.y = randRange(-100,100)
enship.speed = randRange(0.5,1)
ships.push(enship)
end

drawEnship = function()
  screen.setDrawScale(-1,1)
  for e in ships
    screen.drawSprite(e.sprite, e.x, e.y, e.size, e.size)
  end
  screen.setDrawScale(1,1)
end

updateEnship = function()
  local temp = []
  for enships in ships
    enship.x -= enship.speed
    if  enship.x < -240 then
       enship.active = false
    end
     for blast in blasts
       if distance(blast.x, blast.y, 
         enship.x, enship.y) < enship.size/3 then
         enemy.active = false
         blast.active = false
         createExplosion(enship.x, enship.y, 20)
         end
     end
       for blast1 in blasts1
       if distance(blast1.x, blast1.y, 
         enship.x, enship.y) < enship.size/3 then
         enemy.active = false
         blast1.active = false
         createExplosion(enship.x, enship.y, 20)
         end
       end
       
      if enship.active then 
        temp.push(enship)
      end
  end
    enship = temp
    if random.next() < 0.1 then
      createEnship()
    end
    end
//And then this
init = function()
  initBlast1()
  initBlast()
initPlayer1()
initEnship()
end


update = function()
  moveBlast1()
  fireBlast1()
  moveBlast()
  fireBlast()
  updatePlayer1()
  createEnship()
  updateEnship()
end


draw = function()
 drawPlayer1()
    drawBlast()
    drawBlast1()
    drawEnship()
  end

it seems you just made a mistake with the for ### in ### block. The example goes:

list =[2,3,5,5,7,11]
for number in list
  print(number)
end

hope this helps :)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community