1flyingfish = class:new() 2 3function flyingfish:init() 4 self.y = 15 5 self.x = math.random(math.floor(splitxscroll[1]), math.floor(splitxscroll[1])+width) 6 self.width = 12/16 7 self.height = 12/16 8 self.rotation = 0 --for portals 9 10 self.speedy = -flyingfishforce 11 self.speedx = objects["player"][1].speedx + math.random(10)-5 12 13 self.active = true 14 self.static = false 15 self.autodelete = true 16 self.gravity = flyingfishgravity 17 self.category = 27 18 19 self.mask = { true, 20 true, false, true, true, true, 21 true, true, true, true, true, 22 true, false, true, true, true, 23 true, true, true, true, true, 24 true, true, true, true, true, 25 true, true, true, true, true} 26 27 --IMAGE STUFF 28 self.drawable = true 29 self.graphic = cheepcheepimg 30 self.quad = cheepcheepquad[1][1] 31 self.offsetX = 6 32 self.offsetY = 3 33 self.quadcenterX = 8 34 self.quadcenterY = 8 35 36 self.mask = {true, true} 37 38 if self.speedx == 0 then 39 self.speedx = 1 40 end 41 42 if self.speedx > 0 then 43 self.animationdirection = "left" 44 else 45 self.animationdirection = "right" 46 end 47 self.animationtimer = 0 48 49 self.shot = false 50 51 --seems like they take the player's speed and add a random number from -x to x 52 --height is always the same at about "2 pixels above middle of lower font row" 53end 54 55function flyingfish:update(dt) 56 --rotate back to 0 (portals) 57 if self.rotation > 0 then 58 self.rotation = self.rotation - portalrotationalignmentspeed*dt 59 if self.rotation < 0 then 60 self.rotation = 0 61 end 62 elseif self.rotation < 0 then 63 self.rotation = self.rotation + portalrotationalignmentspeed*dt 64 if self.rotation > 0 then 65 self.rotation = 0 66 end 67 end 68 69 if self.shot then 70 self.speedy = self.speedy + shotgravity*dt 71 72 self.x = self.x+self.speedx*dt 73 self.y = self.y+self.speedy*dt 74 75 return false 76 77 else 78 self.animationtimer = self.animationtimer + dt 79 while self.animationtimer > cheepanimationspeed do 80 self.animationtimer = self.animationtimer - cheepanimationspeed 81 if self.frame == 1 then 82 self.frame = 2 83 else 84 self.frame = 1 85 end 86 self.quad = cheepcheepquad[1][self.frame] 87 end 88 89 return false 90 end 91end 92 93function flyingfish:shotted(dir) --fireball, star, turtle 94 playsound(shotsound) 95 self.shot = true 96 self.active = false 97 self.gravity = shotgravity 98 self.speedy = -shotjumpforce 99 self.direction = dir or "right" 100 if self.direction == "left" then 101 self.speedx = -shotspeedx 102 else 103 self.speedx = shotspeedx 104 end 105end 106 107function flyingfish:rightcollide(a, b) 108 if self:globalcollide() then 109 return false 110 end 111 112end 113 114function flyingfish:leftcollide(a, b) 115 if self:globalcollide() then 116 return false 117 end 118 119end 120 121function flyingfish:ceilcollide(a, b) 122 if self:globalcollide() then 123 return false 124 end 125 126end 127 128function flyingfish:floorcollide(a, b) 129 if self:globalcollide() then 130 return false 131 end 132 133end 134 135function flyingfish:globalcollide(a, b) 136 return true 137end 138 139function flyingfish:stomp() 140 self:shotted() 141end