So when I turn to the left, the objects image is upside down. And that really bothers me. Especially when nyan cat is there. Can someone find a way so when the image is to the left, the image flips vertically (I know how to flip an image vertically but I don't know how to set up the code for it)
Thanks in advance!
-tReks
Code For Lobster Class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Lobster extends Animal { private int timer = 200 ; private int pic = 1 ; int nyan = 0 ; int dir = 0 ; public void act() { move(); if ( Greenfoot.isKeyDown( "up" ) ) { move( 20 ); } if ( Greenfoot.isKeyDown( "down" ) ) { move(- 25 ); } if ( Greenfoot.isKeyDown( "right" ) ) { turn( 10 ); } if ( Greenfoot.isKeyDown( "left" ) ) { turn(- 10 ); } if (canSee(Crab. class )) { eat(Crab. class ); Greenfoot.playSound( "au.wav" ); } if ( atWorldEdge() ) { setRotation( getRotation() - 180 ); Worm willy = new Worm(); getWorld().addObject(willy, 0 , 0 ); } if ( Greenfoot.isKeyDown( "space" ) && nyan == 1 ) { Rb rb = new Rb(); getWorld().addObject(rb,getX(),getY()); rb.setRotation(getRotation()); } else { if ( Greenfoot.isKeyDown( "space" )) { Worm wilma = new Worm(); getWorld().addObject(wilma,getX(),getY()); wilma.setRotation(getRotation()); } } if ( timer > 0 ) { timer -= 1 ; } else { if ( pic == 1 ) { setImage( "lobster.png" ); pic += 1 ; nyan = 0 ; timer= 100 ; } else if (( pic == 2 )) { setImage( "frog.png" ); pic += 1 ; nyan = 0 ; timer= 100 ; } else if (( pic == 3 )) { setImage( "frog.png" ); pic = 4 ; nyan = 0 ; timer= 100 ; } else { setImage( "nyan.png" ); nyan = 1 ; pic = 1 ; timer= 300 ; } } } } |