My first game

7 posts

Flag Post

Hey all, I just finished my first game and as it’s mostly meant to improve my skills I was wondering what the people here think of it. I realize the gameplay isn’t that great.

http://www.kongregate.com/games/MilkingTheCowMOO/when-cow-moo

I also have a specific question. In this game I have a lot of repetitive code because every cow requires its own code. As a result I have way too much code that’s nearly identical. How can I prevent this?

 
Flag Post

Give the cow its own custom class?

Firstly, are you using AS2 or AS3?

Would you mind posting some code?

edit: After playing the game, all I can say is wtf????!?!

 
Flag Post

I use AS3. I dont really know how to do solve this with a custom class. I’ve used them twice while following a tutorial but I’m not very good at it yet.

Im currently not at home so I cant provide any code but my repetitive code is similar to this:

cow1.addEventListener(MouseEvent.CLICK, cow1Listener);
cow2.addEventListener(MouseEvent.CLICK, cow2Listener);

function cow1Listener(MouseEvent):void
{
    mcCow1.gotoAndStop("Cut");
}
function cow2Listener(MouseEvent):void
{
    mcCow1.gotoAndStop("Cut");
}

If you would like to see more I’ll upload my code tomorrow.

 
Flag Post

You could go something along the lines of:

addEventListener(MouseEvent.CLICK, clicked)

function clicked(event:MouseEvent):void{
    switch(event.target){
        case "mcCow1":
            mcCow1.gotoAndStop(weaponType)
            break;
        case "mcCow2":
            mcCow2.gotoAndStop(weaponType)
            break;
        default:
            break;
       }
    }
}

You’d have to check what the event target outputs for each of the cows first though, not just use “mcCow1”.
And weaponType would just be the type of weapon you are using, as a String, so that you don’t need to have checks for the weapon type/different event listeners.

You could also go so far as to:
if(event.target is of Class cow) event.target.gotoAndStop(weaponType)
But I don’t know how to do that properly, you’d have to ask someone else.

 
Flag Post

Thanks a lot for your help!

 
Flag Post

What the hell did I just play ಠ_ಠ

 
Flag Post
Originally posted by DannyDaNinja:

What the hell did I just play ಠ_ಠ

It’s a new genere: shut up game.