Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Sprite Animation [Re: Espér] #261078
04/15/09 16:09
04/15/09 16:09
Joined: Apr 2009
Posts: 2
I
igorasdf Offline
Guest
igorasdf  Offline
Guest
I

Joined: Apr 2009
Posts: 2
can you give me a full example please???

something like that?:

action test()
{
ent_animate(...
}

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 Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Code:
#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);

}



Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Sprite Animation [Re: Espér] #261187
04/16/09 09:13
04/16/09 09:13
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
ent_animate will animate the sprite based on its frames stored within. But if u want to animate the sprite itself, i.e. move it around u need to play with its x, y , z values. here is the modified code to ur question

Code:
ENTITY* sprite_anim;


function entity_resize()
{
	sprite_anim.frame = 5;
	sprite_anim.scale_x = -1;
}


void 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(5);
sprite_anim = ent_create("explo+11.tga", vector(0, 0, 0), NULL);
entity_resize();
}




A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: Sprite Animation [Re: delinkx] #261207
04/16/09 10:39
04/16/09 10:39
Joined: Apr 2009
Posts: 248
Philippines
seecah Offline OP
Member
seecah  Offline 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: seecah] #261349
04/17/09 03:45
04/17/09 03:45
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
just post me ur code for the ball catcher. i show u how to keep it over it.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: Sprite Animation [Re: delinkx] #261636
04/19/09 02:57
04/19/09 02:57
Joined: Apr 2009
Posts: 248
Philippines
seecah Offline OP
Member
seecah  Offline 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)

Quote:

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 Offline
User
delinkx  Offline
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:

Code:
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.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: Sprite Animation [Re: delinkx] #261782
04/20/09 07:13
04/20/09 07:13
Joined: Apr 2009
Posts: 248
Philippines
seecah Offline OP
Member
seecah  Offline 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 Offline OP
Member
seecah  Offline 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..
Quote:

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 Offline
User
delinkx  Offline
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:

Code:
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.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Page 2 of 2 1 2

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1