|
|
Re: Sprite Animation
[Re: seecah]
#261134
04/15/09 23:04
04/15/09 23:04
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
Expert
|
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
#include <acknex.h>
#include <default.c>
ENTITY* sprite_anim;
action test()
{
ent_animate(my,"",my.skill99,ANM_CYCLE);
my.skill99 += 4 * time_step;
}
function main()
{
fps_max = 40; // limit the frame rate to 40 fps
video_mode = 8; // run at 1024 x 768 pixels
video_depth = 32; // 32 bit mode
// video_screen = 1; // start in full screen mode
level_load(NULL);
wait(3);
sprite_anim = ent_create("explo+5.tga", vector(200, 200, 0), test);
}
|
|
|
Re: Sprite Animation
[Re: delinkx]
#261207
04/16/09 10:39
04/16/09 10:39
|
Joined: Apr 2009
Posts: 248 Philippines
seecah
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 248
Philippines
|
Thanks delinkx it really helps.. Now I've got a very minor problem. Before moving the ball I want it to be located just above the ball catcher and follow the mouseforce. The ball catcher already follows the mouse and thanks to mercuryus for that but I can't let them go synchronously..
Can't is not an option™
|
|
|
Re: Sprite Animation
[Re: delinkx]
#261636
04/19/09 02:57
04/19/09 02:57
|
Joined: Apr 2009
Posts: 248 Philippines
seecah
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 248
Philippines
|
below is the function i've been calling in the main function to set the ball catcher. then followed by the function that will let the ball move (startBouncing) function setCatcher(PANEL* panCatcher) { panRoundedCatcher = panCatcher; while(1) { panCatcher.pos_x=clamp(panCatcher.pos_x+(time_step*mouse_force.x*50), 0, screen_size.x-bmap_width(panCatcher.bmap)*panCatcher.scale_x); wait(1); } }
Please advise.
Can't is not an option™
|
|
|
Re: Sprite Animation
[Re: seecah]
#261774
04/20/09 04:35
04/20/09 04:35
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
User
|
User
Joined: Jul 2008
Posts: 553
Singapore
|
ok. here when u do panRoundedCatcher = panCatcher; it doesnt attach it to each other. Instead it copies the parameters from one panel to the other. so wat u need to do is move the panels on mouse move. here is the code (tested) for this:
BMAP* paddle = "paddle.pcx";
BMAP* ball = "ball.pcx";
PANEL* panPaddle =
{
pos_x = 40; pos_y = 40;
bmap = paddle;
flags = SHOW;
}
PANEL* panBall =
{
pos_x = 80; pos_y = 20;
bmap = ball;
flags = SHOW;
}
function setCatcher(PANEL* panCatcher)
{
while(1)
{
panCatcher.pos_x=clamp(panCatcher.pos_x+(time_step*mouse_force.x*50), 0, screen_size.x-bmap_width(panCatcher.bmap)*panCatcher.scale_x);
panBall.pos_x=clamp(panBall.pos_x+(time_step*mouse_force.x*50), 0, screen_size.x-bmap_width(panBall.bmap)*panBall.scale_x);
wait(1);
}
}
function main()
{
setCatcher(panPaddle);
}
in the above code, it just moves. U can add in code for once mouse click, then release the ball.
|
|
|
Re: Sprite Animation
[Re: delinkx]
#261782
04/20/09 07:13
04/20/09 07:13
|
Joined: Apr 2009
Posts: 248 Philippines
seecah
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 248
Philippines
|
I think there should be a problem with this code.. The ball will still follow the mousecursor even after it is being released..
Can't is not an option™
|
|
|
Re: Sprite Animation
[Re: seecah]
#261784
04/20/09 07:21
04/20/09 07:21
|
Joined: Apr 2009
Posts: 248 Philippines
seecah
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 248
Philippines
|
I think there should be a problem with this code.. The ball will still follow the mousecursor even after it is being released.. function setCatcher(PANEL* panCatcher, PANEL* panBall) { panRoundedCatcher = panCatcher; while(1) { panCatcher.pos_x=clamp(panCatcher.pos_x+(time_step*mouse_force.x*50), 0, screen_size.x-bmap_width(panCatcher.bmap)*panCatcher.scale_x); if (0 == ballStarted) { panBall.pos_x=clamp(panBall.pos_x+(time_step*mouse_force.x*50), 0, screen_size.x-bmap_width(panBall.bmap)*panBall.scale_x); } wait(1); } }
Can't is not an option™
|
|
|
Re: Sprite Animation
[Re: seecah]
#261788
04/20/09 07:40
04/20/09 07:40
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
User
|
User
Joined: Jul 2008
Posts: 553
Singapore
|
no. u just need to keep track of the launching. suppose a mouse click makes the launch, then a sample code is as follows:
BMAP* paddle = "paddle.pcx";
BMAP* ball = "ball.pcx";
var stick = 1; //stick =1 implies no clicking, stick = 0 implies ball is launched
PANEL* panPaddle =
{
pos_x = 40; pos_y = 40;
bmap = paddle;
flags = SHOW;
}
PANEL* panBall =
{
pos_x = 80; pos_y = 20;
bmap = ball;
flags = SHOW;
}
function ball_launch()
{
stick=0;
while(1)
{
panPaddle.pos_x=clamp(panPaddle.pos_x+(mouse_force.x*2), 0, screen_size.x-bmap_width(panPaddle.bmap)*panPaddle.scale_x);
// put ur ball moving code here
wait(1);
}
}
function setCatcher(PANEL* panCatcher)
{
while(1)
{
if(stick==1)
{
panCatcher.pos_x=clamp(panCatcher.pos_x+(mouse_force.x*2), 0, screen_size.x-bmap_width(panCatcher.bmap)*panCatcher.scale_x);
panBall.pos_x=clamp(panBall.pos_x+(mouse_force.x*2), 0, screen_size.x-bmap_width(panBall.bmap)*panBall.scale_x);
}
on_mouse_left = ball_launch;
wait(1);
}
}
function main()
{
setCatcher(panPaddle);
}
note: Notice i have removed time_step, since if user keeps clicking, the force of motion will increase. To increase or decrease the speed, just play around with the mouse_force.x * 2 >> u can replace 2 by any multiple.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|