void runGame(){
    readimagefile("PIX\\Landscape.jpg", 0, 0, 800, 800);
    while(1 == 1){
        moveCharacter();
        //moveMonster();
    }
}
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();
    //specialAttack();
    //thunderball();
    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;

    default:
        readimagefile("PIX\\Character\\down_still.gif", x9, y9, x9+50, y9+50);
        putimage(0, 0, background, COPY_PUT);
    }
    }//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);

    getmouseclick(WM_LBUTTONDOWN, mx, my);
    if(WM_LBUTTONDOWN){
        printf("Left mouse button was clicked!\n");
        #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);
    }
}

So this is the code I have at the moment. My issue is that it keeps thinking the left mouse button is being clicked constantly. Therefore it is constantly putting the animation in the top left corner and slowing down character movement. I have tried an enourmouse slew of things to stop this but have not been able to figure it out. Google has not helped either. I just don't get how it thinks I am constantly clicking left mouse button. I believe it is because of the if(WM_LBUTTONDOWN) statement. But even that, I have tried changing it, adding different specifications, moving it, getting rid of it, and nothing works out how I need it to. It just constantly thinks left button is being clicked (even when I got rid of if() statement it did this!).

Could anyone help me out on this?

THANKS!

Somewhere in the windows code is a line like this:

#define WM_LBUTTONDOWN                  0x0201

So your code if(WM_LBUTTONDOWN) is essentially saying: if(0x0201) which is essentially if(true)

You're not checking to see if the left mouse button is currently being clicked - you're simply saying if(true)

Edited 3 Years Ago by Moschops

haha I don't really know what else to try... I tried using a switch statement (unsuccessful), I tried getting rid of if() statement and used registermousehandler(WM_LBUTTONDOWN, thunderClaw); and that seemingly works... it just doesn't do the animation. It produces the sound and will only produce the very last image. (registermousehandler() is in main btw.) I just don't get what needs to be done to tell the stupid program to only execute images when mouse is CLICKED! Lol why can't it just do what it needs to!

You haven't helped yourself by trying to do this directly with the Win32 API. The message pump is not a simple piece of code. I'd suggest you pick out one of the simple widget toolkits and start with that.

Lol... oh dear... Hmmm... I am in my first class ever of programming. I suppose I would nee to look up what widget toolkits are as I have no idea... But I might not even be able to use them? My professor has had us using this program he created for the entire class so far that has a graphics screen that we have done stuff with. We might have to use his program for this. This game is term project of our own choosing so me and partner decided to do this.

This article has been dead for over six months. Start a new discussion instead.