How to create a simple fire shot in a game....
Moderators: heatherlaine, kevinmiller, robinmiller, malte
How to create a simple fire shot in a game....
Hy to everybody,
i need to know how to create a simple fire to shot in a game...i must make a list, but i don't know how, and i have also arcade engine 2.9 installed.
So , i need for example when i push the mouse button the shot repeat the fire animation, back to back like a second from each other.......
i thank you so much in advance.......
bye,
LESTROSO
i need to know how to create a simple fire to shot in a game...i must make a list, but i don't know how, and i have also arcade engine 2.9 installed.
So , i need for example when i push the mouse button the shot repeat the fire animation, back to back like a second from each other.......
i thank you so much in advance.......
bye,
LESTROSO
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
hi lestroso,
look at
http://runrev.com/newsletter/january/is ... etter4.php
(last of six articles with links to all the articles)
Robert Cailliau did this 6 part example of a cannon and may be you find some hints for shots in your application. It is an excellent introduction to ballistics and how to calculate this. It may not look like an 'ego-shooter' game but still. It has a lot of basic concepts of revolution very well explained.
regards
bernd
look at
http://runrev.com/newsletter/january/is ... etter4.php
(last of six articles with links to all the articles)
Robert Cailliau did this 6 part example of a cannon and may be you find some hints for shots in your application. It is an excellent introduction to ballistics and how to calculate this. It may not look like an 'ego-shooter' game but still. It has a lot of basic concepts of revolution very well explained.
regards
bernd
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
coming to think of it, may be you wanted to simulate a fire at a pistol when shot?
try making a polygon graphic like an irregular star or what you like, set its opaque to true, set its backgroundcolor to red. If you use rev 3.0 you could set its gradient to radial an choose red and yellow as colors. Call the graphic "myFire", make a button
this gives you a crummy kind of gunfire effect. You could of course elaborate on this changing the size of graphic on the fly or turning the graphic.
I hope I understood you right this time
cheers
bernd
try making a polygon graphic like an irregular star or what you like, set its opaque to true, set its backgroundcolor to red. If you use rev 3.0 you could set its gradient to radial an choose red and yellow as colors. Call the graphic "myFire", make a button
Code: Select all
on mouseUp pMouseBtnNo
set the blendlevel of graphic "myFire" to 0
repeat with i = 1 to 100 step 2 --change to 4 if you want it faster
set the blendlevel of graphic "myFire" to i
wait 1 milliseconds with messages
end repeat
end mouseUp
I hope I understood you right this time
cheers
bernd
Thanks bn,
it's good the example that you have me post, but it's not usefull.....because i need to shot if needed without waiting....and i should create a list of the fire shot because the animations of the shot go for their path in that moment and then go away going to out of card.
Thanks again,,,
do have other ideas????? ........thanks
LESTROSO
it's good the example that you have me post, but it's not usefull.....because i need to shot if needed without waiting....and i should create a list of the fire shot because the animations of the shot go for their path in that moment and then go away going to out of card.
Thanks again,,,
do have other ideas????? ........thanks
LESTROSO
Hi Lestroso,
with animationengine in use, try this in the messagebox:
go url "http://www.derbrill.de/revstack/shootertest2.rev"
Feel free to tear that stack apart. It is rather old, but should get you started.
Cheers,
Malte
with animationengine in use, try this in the messagebox:
go url "http://www.derbrill.de/revstack/shootertest2.rev"
Feel free to tear that stack apart. It is rather old, but should get you started.
Cheers,
Malte
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
hi lestroso,
malte is the best coach for animations. If the cheesy animation I suggested does the job but is not working because it is in a blocking repeat loop then here is a non blocking version this works even if you leave the card since it provides the id of the card, you would have to adapt it to your script just make shure the you provide a valid address for the script. To keep the local variable alive you could put it into a global, for example.
for what it is worth
bernd
malte is the best coach for animations. If the cheesy animation I suggested does the job but is not working because it is in a blocking repeat loop then here is a non blocking version
Code: Select all
local tBlendLevelOfMyFire, tID
on mouseUp pMouseBtnNo
put the id of this card into tID
put 0 into tBlendLevelOfMyFire
send makePistolFire to me in 2 milliseconds
end mouseUp
on makePistolFire
set the blendlevel of graphic "myFire" of card id tID to tBlendLevelOfMyFire
put tBlendLevelOfMyFire + 10 into tBlendLevelOfMyFire
if tBlendLevelOfMyFire < 110 then send makePistolFire to me in 30 milliseconds
end makePistolFire
for what it is worth
bernd
Thanks again bn, for your example.............i saw the example of malte and it's the right example for me, but a little complicated......i understand that malte in that example create many shots on mouseup and mouse still pressed....and then delete them one per time.......ok....i'll study hard that example.......
thanks for your precious time,
Lestroso
thanks for your precious time,
Lestroso
Dear malte.......i'm little confused..... i need your help please......i have made some mistake to modify your stack to adapt in my stack........i don't understand well the movelinear command because it' always repeated in infinite loop not like the aemove......
i would like to know how to modify this program....i have used image...not grafic like you..... so i have insert clone command to create shot....but there's no well animations, but bad .....
i will thank you so much if you will show me an little example to integrate easily in my shooter game....if you can......thank in advance......
Lestroso,
Thanks Lestroso
i would like to know how to modify this program....i have used image...not grafic like you..... so i have insert clone command to create shot....but there's no well animations, but bad .....
i will thank you so much if you will show me an little example to integrate easily in my shooter game....if you can......thank in advance......
Lestroso,
Code: Select all
---------------------SEZIONE SPARO----------------
GLOBAL NEWSHOT
GLOBAL THEANGLE
GLOBAL NEWSHOTS
on createShot
SHOW IMAGE "PROIETTILE"
CLONE IMAGE "PROIETTILE"
put the ID of it into newShot
put findangleX(the loc of IMAGE "fUCILE",the loc of this cd) into theAngle
--put theAngle
set the moveLinear["startPoint"] of IMAGE ID newShot to pointOnCircle(the loc of IMAGE "fUCILE",theAngle,40)
set the moveLinear["endPoint"] of IMAGE ID newShot to pointOnCircle(the loc of IMAGE "fUCILE",theAngle,700)
set the moveLinear["step"] of IMAGE ID newshot to 1
--set the width of grc ID newShot to 10
--set the height of grc ID newShot to 10
send "initmove" to IMAGE ID newShot
vai
end createShot
on initMove
put the allshots of this cd into newShots
put cr&the ID of the target after newShots
if line 1 of newShots is empty then delete line 1 of newShots
set the allshots of this cd to newShots
end initmove
ON VAI
IF the visible of IMAGE ID newShot then
SEND "MOVELINEAR" TO IMAGE ID NEWSHOT
end if
SEND "VAI" TO ME IN 2 MILLISECONDS
--ELSE
--send "movelinearmovedone" to image id newshot
--END IF
end VAI
on movelinearmovedone
hide image id newshot
DELETE IMAGE ID newshot
beep 2
end movelinearmovedone
Dear Malte i have mailed you my stack as requested.....in info@derbrill.de
i will thank you so much for have a look-.....
Bye,
Cheeers,
Lestroso
i will thank you so much for have a look-.....
Bye,
Cheeers,
Lestroso
Hy Malte, i haven't heard any more.....ok don't worry.....but i need help again, because i have problem when i made a series of shots.....i have tried, but without chance.....now here i enclose my little program because i want to create sevel shots when i click the mouse
Now the movelinear is ok for me...but i need an help about to create newshots, i saw in your stack you use " repeat each in" etc........but i don't know how it use it.........
This program is working and movelinear the image called "proiettile" the shot, but what about to move several shots in the mean time back to back?
Thanks again,
Lestroso
Now the movelinear is ok for me...but i need an help about to create newshots, i saw in your stack you use " repeat each in" etc........but i don't know how it use it.........
This program is working and movelinear the image called "proiettile" the shot, but what about to move several shots in the mean time back to back?
Thanks again,
Lestroso
Code: Select all
---------------------SEZIONE SPARO----------------
on createShot
PUT 1 INTO VERIFICA
SHOW IMAGE "PROIETTILE"
--CLONE IMAGE "PROIETTILE"
--put the ID of it into newShot
--Determino punto di partenza proiettile------start shot
PUT AngoloFucile into AngoloProiettile
put (AngoloFucile*pi/180) into AngoloRad
put (tan(AngoloRad)) into TangenteAngolo
put (sin(AngoloRad)) into SenoAngolo
put (cos(AngoloRad)) into CosenoAngolo
put (SenoAngolo/TangenteAngolo)*260 into PosInizXProiettile
put (CosenoAngolo*TangenteAngolo)*260 into PosInizYProiettile
put (PosXFucile+PosInizXProiettile) into PosInizXProiettile
put (PosYFucile-PosInizYProiettile) into PosInizYProiettile
--Determino punto di arrivo proiettile------final point arrive
put PosYFucile into PosFinYProiettile
PUT AngoloFucile into AngoloProiettile
put (AngoloFucile*pi/180) into AngoloRad
put (tan(AngoloRad)) into TangenteAngolo
put (PosFinYProiettile/TangenteAngolo) into PosFinXProiettile
put (PosXFucile+PosFinXProiettile) into PosFinXProiettile
put 0 into PosFinYProiettile
-- set the angle of image ID newShot to AngoloProiettile-90
set the angle of image "proiettile" to AngoloProiettile-90
-- set the moveLinear["startPoint"] of IMAGE ID newShot to POSInizXPROIETTILE,POSInizYPROIETTILE
--
-- set the moveLinear["endPoint"] of IMAGE ID newShot to POSFinXPROIETTILE,POSFinYPROIETTILE
set the moveLinear["startPoint"] of IMAGE "proiettile" to POSInizXPROIETTILE,POSInizYPROIETTILE
set the moveLinear["endPoint"] of IMAGE "proiettile" to POSFinXPROIETTILE,POSFinYPROIETTILE
-- set the moveLinear["step"] of IMAGE ID newshot to 1
set the moveLinear["step"] of IMAGE "proiettile" to 6
sparo
end createShot
on sparo
-- send "movelinear" to image ID newShot
send "movelinear" to image "proiettile"
if VERIFICA= 1 then
send "sparo" to me in 5 milliseconds
end if
end sparo
------------------------------------------------------------------------------------------------
in the objet........proiettile script...........>
global newshot
GLOBAL VERIFICA
on moveLinearMoveDone
PUT 0 INTO VERIFICA
--hide image id newshot
--DELETE IMAGE ID newshot
hide image "proiettile"
beep
end moveLinearMoveDone
Hey lestroso,
sorry I did not get back earlier, somehow the forum does not show me new posts in the ae forum. :/ I have been pretty packed recently, that adds up to me being not too responsive.
Nowadays, I guess I would create shots with aemoveto, as this already sets up the necessary timers and callback messages.
example
on mouseDown
local tID
create grc "shot"
put the long id of it into tID
aeMoveTo tID,0,0,1000,"inout"
end mousedown
then in the card script
on aeMoveDone
if the short name of the target="shot" then
send "deleteIt" to the target in 50 millisecs
end if
end aeMoveDone
on deleteIt
delete the target
end deleteIt
this is out of the top of my head, but should work.
Hth,
Malte
sorry I did not get back earlier, somehow the forum does not show me new posts in the ae forum. :/ I have been pretty packed recently, that adds up to me being not too responsive.
Nowadays, I guess I would create shots with aemoveto, as this already sets up the necessary timers and callback messages.
example
on mouseDown
local tID
create grc "shot"
put the long id of it into tID
aeMoveTo tID,0,0,1000,"inout"
end mousedown
then in the card script
on aeMoveDone
if the short name of the target="shot" then
send "deleteIt" to the target in 50 millisecs
end if
end aeMoveDone
on deleteIt
delete the target
end deleteIt
this is out of the top of my head, but should work.
Hth,
Malte