please help

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

please help

Post by luislasonbra »

hola estoy tratando de crear un juego de tanques, pero ala hora de crear el efecto de los cañones cayendo, no se como hacerlo.

asi que e venido con la siguiente pregunta:
¿alguien podria decirme o orientarme sobre el tema?
!para poder hacer que al lanzar un cañon este haga el efecto de que esta callendo
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: please help

Post by raidho36 »

Ermm...
hello I'm trying to create a set of tanks, but wing when creating the effect of falling cannons, not how.

so and come with the following question:
Could anyone tell me or guide me on the subject?
! to be able to do that by throwing a barrel this makes the effect of which is falling
Okay... I assume you want cannon recoil effect.

Your cannon barrel should be a separate image, obviously. You will also need a variable to remember recoil length and optionally another for recoil speed. When cannon is fired, you set your recoil speed to some negative value, and every update you 1) increase your recoil length by recoil speed and 2) increase recoil speed by some number. Then, when you draw your cannon, to it's X and Y coordinates you add recoil * cos ( angle ) and recoil * -sin ( angle ) respectively.

Code: Select all

local recoil_amp, recoil_spd = 0, 0

love.update ( dt )
-- blah blah blah
if shoot == 1 then
  recoil_spd = -10 --this affects how big recoil is
end
recoil_amp = recoil_amp + recoil_spd
recoil_spd += dt * 0.1 -- this affects how fast recoil stops
if recoil_amp >= 0 then -- this stops recoil
  recoil_amp = 0
  recoil_spd = 0
end 

love.draw ( )
love.graphics.draw ( cannon, cannon_x + recoil_amp * math.sin ( cannon_angle ), cannon_y + recoil_amp * -math.cos ( cannon_angle ), cannon_angle ) 
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: please help

Post by luislasonbra »

raidho36 wrote:Ermm...
hello I'm trying to create a set of tanks, but wing when creating the effect of falling cannons, not how.

so and come with the following question:
Could anyone tell me or guide me on the subject?
! to be able to do that by throwing a barrel this makes the effect of which is falling
Okay... I assume you want cannon recoil effect.

Your cannon barrel should be a separate image, obviously. You will also need a variable to remember recoil length and optionally another for recoil speed. When cannon is fired, you set your recoil speed to some negative value, and every update you 1) increase your recoil length by recoil speed and 2) increase recoil speed by some number. Then, when you draw your cannon, to it's X and Y coordinates you add recoil * cos ( angle ) and recoil * -sin ( angle ) respectively.

Code: Select all

local recoil_amp, recoil_spd = 0, 0

love.update ( dt )
-- blah blah blah
if shoot == 1 then
  recoil_spd = -10 --this affects how big recoil is
end
recoil_amp = recoil_amp + recoil_spd
recoil_spd += dt * 0.1 -- this affects how fast recoil stops
if recoil_amp >= 0 then -- this stops recoil
  recoil_amp = 0
  recoil_spd = 0
end 

love.draw ( )
love.graphics.draw ( cannon, cannon_x + recoil_amp * math.sin ( cannon_angle ), cannon_y + recoil_amp * -math.cos ( cannon_angle ), cannon_angle ) 

gracias esto me funciono de 100%
pero el tipo de juego, que estoy haciendo
es mas o menos parecido a angry birds en la forma de lansar las aves

ejemplo:

si disparo una flecha esta logicamente ira callendo segun balla abansando.

este es el efecto que quiero hacer para los disparos del tanke.

edito:
loque quiero hacer es algo como esto
http://www.mathsisfun.com/games/tanks.html
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: please help

Post by raidho36 »

You welcome.

So you're making Angry Birds Scorched Earth? Sounds like fun.
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: please help

Post by luislasonbra »

raidho36 wrote:You welcome.

So you're making Angry Birds Scorched Earth? Sounds like fun.
no no quiero hacer un angry birds
solo quiero hacer que cuando dispare un cañon este caiga progresivamente
User avatar
NightKawata
Party member
Posts: 294
Joined: Tue Jan 01, 2013 9:18 pm
Location: Cyberspace, Room 6502
Contact:

Re: please help

Post by NightKawata »

luislasonbra wrote: no no quiero hacer un angry birds
solo quiero hacer que cuando dispare un cañon este caiga progresivamente
my attempted translation wrote: no no I don't want to make an angry birds
I want to make it when (you) shoot a cannon it'll (?) fall progressively
Also, can you please either translate your posts, or stop speaking in spanish, please?
(se puede utilizar la traduccion de tu palabras, o no hables en la español, por favor?) (again, another crappy translation done by me)
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: please help

Post by Robin »

luislasonbra, it might be useful to check out Duolingo, you can learn English there and knowing English is a really useful skill. Especially in the world of games.
Help us help you: attach a .love.
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: please help

Post by Eamonn »

Robin wrote:luislasonbra, it might be useful to check out Duolingo, you can learn English there and knowing English is a really useful skill. Especially in the world of games.
Duolingo! I found out about that app through All About Android and I'm happy I did! It's a lot of fun! :D :D
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: please help

Post by luislasonbra »

thanks I've managed to do what he wanted.
here I leave the file love
Functions Math.png
Functions Math.png (260.86 KiB) Viewed 4133 times
Tutorial 3 - Functions Math.love
(19.18 KiB) Downloaded 241 times
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests