Oh... thanks>:D
I tried implementing dt checking into my code, but unfortunately.... it does not do anything now,
It showed the last image before.. now it shows nothing.
This is in tank.lua (I used require"")
space_pressed = false
bullet = love.graphics.newImage("Images/bullet.png")
exp1 = love.graphics.newImage("Images/exp1.png")
exp2 = love.graphics.newImage("Images/exp2.png")
exp3 = love.graphics.newImage("Images/exp3.png")
less = 200
wait = 1
waiter = 1
debounce = true
state = 'nothing'
function love.update(dt)
if state == 'nothing' then
state = 'waiting'
timer = 0.08
end
if state == 'waiting' then
timer = timer - dt
end
if timer <= 0 then
state = 'nothing'
end
end
function attack()
debounce = false
bulletxpos = xpos
bulletypos = ypos
love.graphics.setColor(255,255,255)
if state == 'nothing' then
state = 'waiting'
Bullet = love.graphics.draw(bullet,bulletxpos,bulletypos)
repeat bulletpos = bulletpos - 1 until bulletpos == xpos - less
end
if state == 'nothing' then
state = 'waiting'
EXP1 = love.graphics.draw(exp1,bulletxpos,bulletypos - less)
end
if state == 'nothing' then
state = 'waiting'
EXP2 = love.graphics.draw(exp2,bulletxpos,bulletypos - less)
end
if state == 'nothing' then
state = 'waiting'
EXP3 = love.graphics.draw(exp3,bulletxpos,bulletypos - less)
space_pressed = false
debounce = true
end
end
This is ithe part of main.lua where it does attack function
function love.draw()
if space_pressed == true and debounce == true then
attack()
end
Help please
Delay on a loop?
Re: Delay on a loop?
1) You should post a love file or post a full code in any other way
2) When posting a code on the forum use the 'code' tag
3) use the space or tab to highlight the scopes like here: http://love2d.org/forums/viewtopic.php?p=163955#p163955
In other words: “Help us to help You”
the possible problems:
1) missing end (but you likely did not copy it correctly)
2) if you have GLOBAL functions with the SAME NAME in tank.lua and main.lua and you use the require at the beginning of main lua, then the functions in main.lua will overwrite the ones in tank.lua
3) lets say that timer is 0 or less and the state is 'waiting':
the state will be set to 'nothing'
love.draw is always called after love.update do attack() will also be called after love update
if state is 'nothing' then attack() will always set it to 'waiting' but timer will not change
in the next frame the state is still 'waiting' and the timer will not reset...
removing state = 'waiting' from attack() should fix it...
2) When posting a code on the forum use the 'code' tag
3) use the space or tab to highlight the scopes like here: http://love2d.org/forums/viewtopic.php?p=163955#p163955
In other words: “Help us to help You”
the possible problems:
1) missing end (but you likely did not copy it correctly)
2) if you have GLOBAL functions with the SAME NAME in tank.lua and main.lua and you use the require at the beginning of main lua, then the functions in main.lua will overwrite the ones in tank.lua
3) lets say that timer is 0 or less and the state is 'waiting':
the state will be set to 'nothing'
love.draw is always called after love.update do attack() will also be called after love update
if state is 'nothing' then attack() will always set it to 'waiting' but timer will not change
in the next frame the state is still 'waiting' and the timer will not reset...
removing state = 'waiting' from attack() should fix it...
Re: Delay on a loop?
Thank you, I have removed that, but unfortunately, it still is not working.
Might I ask how to attach a .love?
Thank you....
Might I ask how to attach a .love?
Thank you....
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Delay on a loop?
How to make a .love: ZIP the contents of your game folder (not the folder itself, its contents!). Then rename mygame.zip to mygame.love.
How to attach it: when you make a post on the forums, below the post-entering-field, there is a tab that says "Upload attachment". Click it. Click "browse", open your .love file, click "Add the file", and submit your post.
How to attach it: when you make a post on the forums, below the post-entering-field, there is a tab that says "Upload attachment". Click it. Click "browse", open your .love file, click "Add the file", and submit your post.
Help us help you: attach a .love.
Re: Delay on a loop?
You should check out this article:
http://www.love2d.org/wiki/Game_Distribution
Alternatively you can open any .love file with an archiving application, remove the content add replace it with the files and folders from Your project folder
Also a blue screen is not 'nothing' but an error! You should learn what each error massage means, and if you don't know post the massage on the forum (VERY INPORTANT if you relay want to receive any useful help)
Learn to format the code – if you do it correctly – things like missing or misplaced end will be easy to spot (the example how to format the code is in the attachment)
And finally You should describe what the code should be doing (What are You trying to make?)
the attachment should run, but it likely wont work as You want (I don't know what You want), it is also commented (what in My opinion was wrong).
http://www.love2d.org/wiki/Game_Distribution
Alternatively you can open any .love file with an archiving application, remove the content add replace it with the files and folders from Your project folder
Also a blue screen is not 'nothing' but an error! You should learn what each error massage means, and if you don't know post the massage on the forum (VERY INPORTANT if you relay want to receive any useful help)
Learn to format the code – if you do it correctly – things like missing or misplaced end will be easy to spot (the example how to format the code is in the attachment)
And finally You should describe what the code should be doing (What are You trying to make?)
the attachment should run, but it likely wont work as You want (I don't know what You want), it is also commented (what in My opinion was wrong).
- Attachments
-
- aTankGame.love
- (25.07 KiB) Downloaded 209 times
Re: Delay on a loop?
I want the bullet animations to slow down, instead of zooming through them until you cannot see.
Also, I do not see what your game changed except the tank pic.
Also, I do not see what your game changed except the tank pic.
Re: Delay on a loop?
Also, in your game, I do not see any shooting animations
I see you made pictures for it... but it is not there.... perhaps something went wrong?
I see you made pictures for it... but it is not there.... perhaps something went wrong?
Re: Delay on a loop?
It waiting works great now! Thanks for all ur guy's help!
Who is online
Users browsing this forum: No registered users and 6 guests