Search found 10 matches
- Fri Jun 19, 2015 8:05 pm
- Forum: Support and Development
- Topic: Why doesn't this death fucntion work?
- Replies: 1
- Views: 1508
Why doesn't this death fucntion work?
I just want it so if an enemy is in the same position with the player it kills them I made this code function and it doesn't work. function enemy_player_collide() for i,v in ipairs(enemy) do for ia, va in ipairs(player) do if va.x == v.x and va.y == v.y then va.x = 0 end end end end
- Thu Jun 18, 2015 8:53 pm
- Forum: Support and Development
- Topic: My enemies keep moving right.
- Replies: 4
- Views: 3285
Re: My enemies keep moving right.
Hi! 1) There is probably no reason to divide enemy x and y by 2 when comparing it with centre position of the player (if there is the there is the issue :)) 2) you compare x and y but then only update xvel of the enemy, not sure if enemy is list of enemies (suggested by the loop) or single one (sug...
- Thu Jun 18, 2015 8:47 pm
- Forum: Support and Development
- Topic: My enemies keep moving right.
- Replies: 4
- Views: 3285
Re: My enemies keep moving right.
Nvm, it's fixedDeltaF1 wrote:It looks like you've put some if statements in the wrong places. Could you upload a .love file so the context is clear?
- Thu Jun 18, 2015 8:18 pm
- Forum: Support and Development
- Topic: My enemies keep moving right.
- Replies: 4
- Views: 3285
My enemies keep moving right.
Hello, I am wrathguy78 and I am making a game where you have to shoot enemies to win! I made the AI so the enemies follow the player but they are only heading right. This is the code: function enemy.AI(dt) for i,v in ipairs(enemy) do if player.x + player.width / 2 < v.x / 2 then if v.xvel > -enemy.s...
- Sun Apr 19, 2015 8:19 pm
- Forum: Support and Development
- Topic: Attempt to call field 'player_collide' (a nil value)
- Replies: 3
- Views: 2114
Re: Attempt to call field 'player_collide' (a nil value)
Also the main: require "player" require "bullet" require "camera" require "map" require "enemy" function love.load() end function love.keypressed(key) player.shoot(key) function love.update(dt) player.death() enemy.player_collide() enemy.generate(dt)...
- Sun Apr 19, 2015 8:10 pm
- Forum: Support and Development
- Topic: Attempt to call field 'player_collide' (a nil value)
- Replies: 3
- Views: 2114
Attempt to call field 'player_collide' (a nil value)
So, it won't call the function even though its their in enemy! The code in enemy is: enemy = {} enemy.timer = 0 enemy.timerLim = math.random(2,3) enemy.amount = math.random(1,5) enemy.side = math.random(1,3) function enemy.generate(dt) enemy.timer = enemy.timer + dt if enemy.timer > enemy.timerLim t...
- Sun Apr 19, 2015 3:34 pm
- Forum: Support and Development
- Topic: Attempt to perform arithmetic on local 'dt' a nil value
- Replies: 2
- Views: 4609
Re: Attempt to perform arithmetic on local 'dt' a nil value
Thank you!Skeiks wrote:You need to pass dt into the move function.
bullet.move(dt)
- Sun Apr 19, 2015 3:08 pm
- Forum: Support and Development
- Topic: Attempt to perform arithmetic on local 'dt' a nil value
- Replies: 2
- Views: 4609
Attempt to perform arithmetic on local 'dt' a nil value
So, I am trying to make a gun game and when I press right, left, up or down it is supposed to shoot a bullet, but I get that error! Heres the error: bullet.lua:28: attempt to perform arithmetic on local 'dt' a nil value bullet = {} bullet.width = 5 bullet.height = 5 bullet.speed = 500 function bulle...
- Sun Jul 27, 2014 7:48 pm
- Forum: Support and Development
- Topic: Error?
- Replies: 4
- Views: 3001
Re: Error?
When i remoe the end it says main.lua :57: 'end' expected (to close 'function' at line 3) near '<eof>
- Sun Jul 27, 2014 4:57 pm
- Forum: Support and Development
- Topic: Error?
- Replies: 4
- Views: 3001
Error?
My window says main.lua:11: attempt to index global 'ents' (a nil value) my code is: function love.load() require ("entities") ents.Startup() love.graphics.setBackgroundColor( 255, 255, 255 ) xCloud = 0 imageCloud = love.graphics.newImage("textures/cloud.png") end for i = 1, 8 do...