I have a fishing game where theres a bubble image moving towards you and when you reel in your fishing rod while touching the bubble, you catch a fish and the bubble respawns at its initial spawnpoint. To increase the difficulty I want the bubble to move slightly faster each time its respawned. How would I do this?
relevant code for fisherman class:
relevant code for world:
Bubble class:
boolean reeling() { if (currAnim == reelLeft || currAnim == reelRight) { setImage(); if(animTimer == 0) { setAnimation(currAnim == reelLeft ? walkLeft : walkRight); if (isTouching(Bubbles.class)) { ((MyWorld)getWorld()).getFish(); removeTouching(Bubbles.class); MyWorld world = (MyWorld) getWorld(); world.spawnBubbles(); } } else { return true; } }
public void spawnBubbles() { Bubbles b = new Bubbles(); int x = 500; int y = 290; addObject (b, x, y); }
public class Bubbles extends Actor { /** * Act - do whatever the bubbles wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ GreenfootImage bubble = getImage(); int speed = 10; int timer; public void Bubbles() { bubble.scale(1, 1); } public void act() { int x = getX(); int y = getY(); if(++timer % speed == 0) { setLocation(x - 5, y); } MyWorld world = (MyWorld)getWorld(); if(getY() >= world.getWidth()) { world.gameOver(); } } }