Jump to content




Hitboxes not functioning


  • You cannot reply to this topic
5 replies to this topic

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 12 December 2014 - 12:44 AM

It is somehow impossible to die in this hitbox testing thingy I did. I'm not sure how, or why it's not registering, but it's not.
Spoiler


#2 Agent Silence

  • Members
  • 319 posts
  • Location[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)

Posted 12 December 2014 - 01:46 AM

Go to the sides

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 December 2014 - 06:15 AM

local player = { x = math.floor(maxx/2), y = math.floor(maxy - 3) }


#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 12 December 2014 - 02:15 PM

View PostRequiem, on 12 December 2014 - 01:46 AM, said:

Go to the sides

What?

View PostBomb Bloke, on 12 December 2014 - 06:15 AM, said:

local player = { x = math.floor(maxx/2), y = math.floor(maxy - 3) }
Yeah, that's a line of code... but I doubt it causes the problem.

#5 AgentE382

  • Members
  • 119 posts

Posted 12 December 2014 - 09:23 PM

You'll want to check for collisions every time anything moves. I suggest moving that code into a function, then calling it after each enemy movement, and each player movement. Right now, your code only checks every .1 seconds.

EDIT:

View PostKingofGamesYami, on 12 December 2014 - 02:15 PM, said:

View PostRequiem, on 12 December 2014 - 01:46 AM, said:

Go to the sides

What?

View PostBomb Bloke, on 12 December 2014 - 06:15 AM, said:

local player = { x = math.floor(maxx/2), y = math.floor(maxy - 3) }
Yeah, that's a line of code... but I doubt it causes the problem.
LOL, this is actually why it's likely not working. Replace your line 9 with Bomb Bloke's version. One or both of the terminal sizes is likely not divisible by two, so you've got non-integer player coordinates. None of your enemies will be at the same coordinate as the player, ever.

Edited by AgentE382, 12 December 2014 - 09:24 PM.


#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 13 December 2014 - 07:01 AM

Bomb bloke is definitely correct, 51/2 is 25.5 which renders as 25, but will never line up with the enemies. as a side point, you should probably consider changing the structure of your code to be a little more logical, perhaps a basic game loop could assist you

while true do
  gatherInput()
  updateGame()
  renderGame()
end






4 user(s) are reading this topic

0 members, 4 guests, 0 anonymous users