A Table of Tables that can be randomly selected by a function

Thanks to your help, I was able to figure this out. So… I guess I owe you $10. :slight_smile:

There is another problem. Heh. no surprise here, it is with vectors, but it does not involve bullets or turrets. 

What I am trying to do is something like 6:27 to 6:33 in my second post. For now, I just want that to happen once and here is what I tried. 

function attack.smack(player, target) local hitBox = createContainer(parent, 500, 500) local player local angle = 0 local vec = ssk.math2d.angle2Vector( angle, true ) vec = ssk.math2d.add( target, vec ) player = vec end --this is how it is called in main.lua: local character = ssk.display.newCircle( group, centerX, centerY, { fill = \_R\_, radius = 10 }) physics.addBody(character, "dynamic", {isSensor = true}) local target = display.newRect(1, 1, 0, display.actualContentHeight) attack.smack(character, target)

I know for sure that the problem is with the vector coding I attempted to create in the attack.smack function.

More like this I I should think

--local angle = 0 local vec = ssk.math2d.diff( player, target ) vec = ssk.math2d.normalize(vec)

Thanks, but it still does not do anything. I added a print function to make sure it was being called and it is. This is the code now:

function attack.smack(player, target) local hitBox = createContainer(parent, 500, 500) local vec = ssk.math2d.diff( player, target ) vec = ssk.math2d.normalize(vec) end --how it is called local target = display.newRect(5, 5, 10, 10) attack.smack(character, target)

I tried placing setLinearVelocity for the player, but that did not work neither. And again, I am feeling kind of bad that you are doing all my work again, so if you could just point me in the right direction, I could try to take it from there.

I’m stuck.  I don’t get what you’re trying to do. Sorry.

local impulseStrength = 10 function attack.smack(player, target) local hitBox = createContainer(parent, 500, 500) local vec = ssk.math2d.diff( player, target ) vec = ssk.math2d.normalize(vec) vec = ssk.math2d.scale( impulseStrength \* player.mass ) player:applyLinearImpulse( vec.x, vec.y, player.x, player.y ) end

I’m still really confused by your code.  You’ve got a lot of things mixed together that don’t go together.

I have to ask.  Why are you trying to replicate undertale?  i.e. What is your goal?  Fun or learning?  You can have both, but… if it is learning I’d start with something way simpler.  

If you’re trying to learn about game development you would be better served starting with games that demonstrate basic mechanics:

  • Action-ish:
    • one-player pong
    • two-player pong
    • breakout
    • whack-a-mole
    • asteroids
  • Board-ish:
    • boggle
    • hangman

Its kind of both, but I got a bit too caught up. I will probably start on pong, that would be a good way to get started on 2D Math.