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
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!

New Topic/Question
Reply



MultiQuote



|