8 Replies - 545 Views - Last Post: 24 March 2013 - 04:40 AM Rate Topic: -----

#1 Bawnawgwa  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 123
  • Joined: 21-January 13

Animation and movement question for my game.

Posted 20 March 2013 - 10:09 PM

Ok... So this is a lot :P

void movement1(){

	if(x9 == 0){
		x9 = 590;
	}

}

void movement(){
	while (1 ==1){
	int move = 0;

	readimagefile("PIX\\black.jpg",0,0,640,480);
	//readimagefile("PIX\\char_1_down.jpg",x9,y9,x9+50,y9+50);
	
	movement1();
	moveMonster();

	if(kbhit()){///right

		if(getch()== 'd'){
		move = 1;
		}
	if(getch()== 'a'){
		move =  3;
		}
	if(getch()== 'w'){
		move = 2;
		}
	if(getch()== 's'){
		move = 4;
		}

	if(getch() == '2'){
		specialAttack();}
	if(getch() == 'i'){
		#ifdef SOUNDfx
		PlaySound("SOUNDS\\Electricity_Shock_Sound_Effect.wav", NULL, SND_ASYNC);
		#endif
		readimagefile("PIX\\thunderclaw00.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw01.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw0.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw2.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw3.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw4.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\thunderclaw5.gif", x9+5, y9-60, x9+50, y9-100);Sleep(80);
		readimagefile("PIX\\clear.gif", x9+5, y9-60, x9+50, y9-100);}

	if(getch() == 'k'){
		#ifdef SOUNDfx
		PlaySound("SOUNDS\\Electricity_Shock_Sound_Effect.wav", NULL, SND_ASYNC);
		#endif
		readimagefile("PIX\\thunderclaw00.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw01.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw0.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw2.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw3.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw4.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\thunderclaw5.gif", x9+5, y9+60, x9+50, y9+100);Sleep(80);
		readimagefile("PIX\\clear.gif", x9+5, y9+60, x9+50, y9+100);
}
	if(getch() == 'l'){
		#ifdef SOUNDfx
		PlaySound("SOUNDS\\Electricity_Shock_Sound_Effect.wav", NULL, SND_ASYNC);
		#endif
		readimagefile("PIX\\thunderclaw00.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw01.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw0.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw2.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw3.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw4.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw5.gif", x9+60, y9+5, x9+100, y9+50);Sleep(80);
		readimagefile("PIX\\clear.gif", x9+60, y9+5, x9+100, y9+50);}

	if(getch() == 'j'){
		#ifdef SOUNDfx
		PlaySound("SOUNDS\\Electricity_Shock_Sound_Effect.wav", NULL, SND_ASYNC);
		#endif
		readimagefile("PIX\\thunderclaw00.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw01.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw0.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw2.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw3.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw4.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\thunderclaw5.gif", x9-60, y9+5, x9-100, y9+50);Sleep(80);
		readimagefile("PIX\\clear.gif", x9-60, y9+5, x9-100, y9+50);}

	}
	if(x9 <= 0){
		x9 = 580;
	}
	if(y9 <= 0){
		y9 = 420;
	}

	if(x9 >= 590){
		x9 = 0;
	}
	if(y9 >= 430){
		y9 = 0;
	}


readimagefile("PIX\\down_still.gif",x9,y9,x9+50,y9+50);
	switch (move){

	case 1://right


		readimagefile("PIX\\left_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		readimagefile("PIX\\left_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		readimagefile("PIX\\left_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		readimagefile("PIX\\left_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		break;

	case 2://up

		readimagefile("PIX\\up_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		readimagefile("PIX\\up_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		readimagefile("PIX\\up_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		readimagefile("PIX\\up_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		break;

	case 3://left

		readimagefile("PIX\\right_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		readimagefile("PIX\\right_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		readimagefile("PIX\\right_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		readimagefile("PIX\\right_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		break;


	case 4://down
		
		 
		readimagefile("PIX\\down_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		readimagefile("PIX\\down_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		readimagefile("PIX\\down_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		readimagefile("PIX\\down_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		break;
		}

	}//end while

}//end function

void specialAttack(){

			#ifdef SOUNDfx
			PlaySound("SOUNDS\\Special_attack2.0.wav", NULL, SND_ASYNC);
			#endif
			readimagefile("PIX\\Special00.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special01.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special03.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special04.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special05.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special06.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special07.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special08.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special09.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special10.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special11.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special12.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special13.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special14.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special15.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special16.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special17.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special18.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special19.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special20.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special21.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special22.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special23.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special24.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special25.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\Special26.jpg", x9-70, y9+60, x9+150, y9+250);Sleep(100);
			readimagefile("PIX\\clear.jpg", x9-70, y9+60, x9+150, y9+250);
}

int Monster1(int direction){
	//srand(time(NULL));
	//x = rand() % 590;
	//y = rand() % 430;

	//getimage(x, y, x+50, y+50, "PIX\\Monster_down_l.gif");

	switch (direction){

case 0:
	direction == 0;
	y = y+1; 
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
	break;

case 1:
	direction == 1;
	y = y+1; 
	x = x+1;
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
	break;

case 2:
	direction == 2;
	x = x+1; 
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
	break;

case 3:
	direction == 3;
	x = x+1;
	y = y-1; 
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
	break;

case 4:
	direction == 4;
	y = y-1; 
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
	break;

case 5:
	direction == 5;
	y = y-1;
	x = x-1;
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
	break;

case 6:
	direction == 6;
	x = x-1; 
//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
break;

case 7:
	direction == 7;
	x = x-1; 
	y = y+1;
	//putimage(x, y, "PIX\\Monster_down_l", XOR_PUT);
	//readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);
break;

}//switch ends

readimagefile("PIX\\Monster_down_l.gif", x, y, x+50, y+50);

//collision detected
if (x > 620 || y > 460 || x < 20 || y < 20) return 1;

else return 0;
}

int moveMonster(){

int directions = 1;
int collisions = 0;
//cleardevice();//Gets rid of welcome picture for testing purposes.

//Introducing the background picture in here causes a smear effect
//readimagefile("PIX\\pinball_machine.jpg",0,0,640,480);


while(1){

collisions = Monster1(directions);
if(collisions){ directions--;
if(directions < 0 ) directions = 7;

}
Sleep(3);//Changed this to sleep command and Sleep(3) is a lovely speed.
cleardevice();//Gets rid of trail
if (kbhit()) {getch(); break;}

}//while

return 0;}



This is the beginnings of my short adventure game I am making. My two problems at the moment are as thus:
1)Is there a better way to animate my character? (character movement animated with all readimages() involving "down_l", "down_r", etc...) He moves around, but he has a trail as it produces the 4 images per cycle before clearing the images, I want no trail to occur :P.
2)My monster and character can't move at the same time. My monster will recognize borders IF I don't move character... But character will not move at all as long as monster is there. And if I try to move character, monster just leaves screen. Do I need monster movement in a whole new .c or .h program and call it to the program file I pasted above? I feel it has to do with x and y value of screen is confused because it is one thing for monster and another for character.

Thanks for any help!

Is This A Good Question/Topic? 0
  • +

Replies To: Animation and movement question for my game.

#2 Adak  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,168
  • Joined: 01-April 11

Re: Animation and movement question for my game.

Posted 20 March 2013 - 11:28 PM

You want to:

1) Read the image file, and put it into an array.

2) put the image down in different locations, but read the background area behind the image (enough to cover any length of his move).

3) so when the image moves, the former background on that side is put back, as well. You don't want to have to redraw the entire screen every time there is a movement.

4) and only put the image onto the screen again, when he's being moved - not all the time, in a while loop. Console buffer can't keep up with that.

I'm not a game programmer, so I'm sure there are more tips for you in a games section or forum.

This post has been edited by Adak: 20 March 2013 - 11:30 PM

Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3163
  • View blog
  • Posts: 9,556
  • Joined: 05-May 12

Re: Animation and movement question for my game.

Posted 21 March 2013 - 05:57 AM

The other thing is that you need to change your game loop logic. Right now you have animation interspersed with your input collection. You want you game loop to look something like:
game_state = init_game_state();
time = 0;
while (!quit)
{
    input = get_input();
    game_state = compute_new_game_state(time, input, game_state);
    render_game_state(game_state);
    time = increment_time(time);
}



Your get_input() should not wait for user input if there is none. It looks like you are already trying to do that with your kbhit() check above, but unfortunately you failed with your multiple getch() calls.

The compute_new_game_state() takes the current game time, user input, and the previous game state into account. For example, if the car is moving forward, and the user input was press on the brakes, you'll want to reduce the car's speed by a little bit depending on your deceleration curve. The time and the previous state let's you figure out where in the curve you should be. If you were animating an action, the new game state should reflect the what the next frame of the animation action is supposed to be.

The render_game_state() simply renders what the game state says things should be.

Although game time should really be part of the game state, most game devs keep it outside as part of the loop. This is to help encapsulate the idea of game time. By accelerating game time, you can get the effect of many days going by in a matter of seconds, by slowing it down, you can get a slow motion effect.
Was This Post Helpful? 0
  • +
  • -

#4 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 710
  • View blog
  • Posts: 2,033
  • Joined: 20-March 10

Re: Animation and movement question for my game.

Posted 21 March 2013 - 11:04 AM

Just out of curiousity what are the functions

putimage and readimagefile ???

Is it Direct2d or a library like SDL or SFML ??

really you should be loading images in a Intialise_Game(); Routine
into image containers then using your putimage to do the rendering of all objects
in a render_game routine as Skydiver has said.

better still encapsulate the game (or level) in a Game class so you could do

Game new_game;
game_state = new_game.Init();

new_game.time =0;// now time is inside the class

while(!quit)
{
 input =get_input();
 game_state=  new_game.game_state(input,game_state);
 new_game.render();
 new_game.time  = new_game.increase_time();
}


Regards

Snoopy.

This post has been edited by snoopy11: 21 March 2013 - 11:04 AM

Was This Post Helpful? 1
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3163
  • View blog
  • Posts: 9,556
  • Joined: 05-May 12

Re: Animation and movement question for my game.

Posted 21 March 2013 - 12:35 PM

Those are from Borland's BGI: http://www.cs.colora.../doc/index.html
It's an ancient API, and wasn't well thought out. That's why in another thread, I mentioned that I ended up writing my own graphics package.
Was This Post Helpful? 0
  • +
  • -

#6 Bawnawgwa  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 123
  • Joined: 21-January 13

Re: Animation and movement question for my game.

Posted 22 March 2013 - 09:30 PM

void runGame(){
	readimagefile("PIX\\Landscape.jpg", 0, 0, 800, 800);
	
	while(1 == 1){
		moveCharacter();
	
	}
}
void moveCharacter(){
	int move = 0;
	int size = imagesize(0, 0, 800, 800);
	void *background = malloc(size);
	getimage(0, 0, 800, 800, background);

	//readimagefile("PIX\\Character\\down_still.gif",x9,y9,x9+50,y9+50);
	thunderClaw();

	if(kbhit()){

	if(getch()== 'd'){
		move = 1;
		}
	if(getch()== 'a'){
		move =  3;
		}
	if(getch()== 'w'){
		move = 2;
		}
	if(getch()== 's'){
		move = 4;
		}
	}
	
	switch (move){
		
	case 1://left

		readimagefile("PIX\\Character\\left_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\left_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\left_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\left_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 + 5;
		putimage(0, 0, background, COPY_PUT);
		break;

	case 2://up

		readimagefile("PIX\\Character\\up_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\up_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\up_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\up_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 - 5;
		putimage(0, 0, background, COPY_PUT);
		break;

	case 3://right

		readimagefile("PIX\\Character\\right_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\right_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\right_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\right_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		x9 = x9 - 5;
		putimage(0, 0, background, COPY_PUT);
		break;


	case 4://down
		 
		readimagefile("PIX\\Character\\down_l.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\down_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\down_r.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Character\\down_still.gif",x9,y9,x9+50,y9+50);Sleep(15);
		y9 = y9 + 5;
		putimage(0, 0, background, COPY_PUT);
		break;
		}

	}//end function

void thunderClaw(){
	int mx = mousex();
	int my = mousey();

	int size = imagesize(0, 0, 800, 800);
	void *background = malloc(size);
	getimage(0, 0, 800, 800, background);

	if(WM_LBUTTONDOWN){
		getmouseclick(WM_LBUTTONDOWN, mx, my);
		#ifdef SOUNDfx
		PlaySound("SOUNDS\\Electricity_Shock_Sound_Effect.wav", NULL, SND_ASYNC);
		#endif
		readimagefile("PIX\\Thunderclaw\\thunderclaw00.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw01.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw0.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw2.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw3.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw4.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
		readimagefile("PIX\\Thunderclaw\\thunderclaw5.gif", mx-25, my-25, mx+25, my+25);Sleep(80);
		putimage(0, 0, background, COPY_PUT);
	}
}





This is updated code :P I have taken quite a bit out of it as I am in the process of cleaning it up. I thought I was smart with the putimages to get rid of trails and clear screen when done. And it does this :P. However, when introducing thunderClaw(), it constantly loops the animation in the top left corner making moving horribly laggy. I don't quite understand how this looping is occurring up there. I have it so IF i press the left mouse button it goes through animation, So I don't see how it is doing it on its own... Especially at (0,0)...

And I am in graphics.h library. My professor said I should not leave graphics.h because if I could handle another graphics library, I should not even be in that class haha... So clearly I wouldn't be able to handle even the next one up at the moment.
Was This Post Helpful? 0
  • +
  • -

#7 Bawnawgwa  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 123
  • Joined: 21-January 13

Re: Animation and movement question for my game.

Posted 23 March 2013 - 09:06 PM

Any help regarding new code/questions...... at all?
Was This Post Helpful? 0
  • +
  • -

#8 Adak  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,168
  • Joined: 01-April 11

Re: Animation and movement question for my game.

Posted 23 March 2013 - 09:55 PM

Don't you think you got a LITTLE carried away with your development?

Get one function's basics working correctly, before you get working on the next function. Testing each, as you go. You'll have to back up now, by REM'ing out /* */ sections of code to find this error. The good thing is it probably won't take as long as it seems, and you probably won't make this rookie move, anytime soon.

No one knows your code as well as you do, and I don't think anyone can look at your code (cold), without running it, and clearly see the details here. Your time to practice debugging code, has arrived, imo. Borland has a good debugger, and remember, the bugs can maybe run, but they can't hide!

Good luck, and remember not to develop your programs like this.
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3163
  • View blog
  • Posts: 9,556
  • Joined: 05-May 12

Re: Animation and movement question for my game.

Posted 24 March 2013 - 04:40 AM

Your if on line 112 is always true because WM_LBUTTONDOWN is non zero.

Memory allocation in the generation of compilers that Borland belongs to is slow. You are calling malloc every frame in movecharacter(). As best as I can tell you also fail to free the memory.

You are still trying to mix getting input and animation.

You still have one kbhit(), but multiple getch().

Sent from my T-Mobile G2 using Tapatalk 2

You are still reading images from disk every frame. Try losing just once at game initialization, and using putimage later.

And lastly, you have sleeps in your animation loop. You need a better mechanism to keep other animation going, but seemingly make others pause. This is why I introduced the concept of game time to you above.

Sent from my T-Mobile G2 using Tapatalk 2
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1