This site requires JavaScript, please enable it in your browser!
Greenfoot back

Max-Felix's Comments

Back to Max-Felix's profile

how to do that?
i know there is somebody out there who knows why the attacks dont hurt the enemy... help me please :(
Max-FelixMax-Felix

2014/12/13

ups, doesnt work here?!
lol, if i defeat the boss and then stand on him, just to get my health bar to 0 and then reset, i have unlimited life :DDD so the problem must be somewhere in your health-bar?!
Ok ich glaub pl = 1; bzw pl = 2; muss man in act ändern und nicht unten
Ok thanks
uh, and if i died once and reset the game, why am i still dead?
nice game, but you definitly have to add something like a menu and i dont know if i just stood wrong, but can the player dodge a arrow from the side by standing 1 field deeper (if you go downwards from spawn). also add more levels pls
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; import java.awt.RadialGradientPaint; import java.awt.Graphics2D; /** * Write a description of class AimDisplay here. * * @author (your name) * @version (a version number or a date) */ public class AimDisplay extends Actor { private HumanPlayer player; private int radius; private static int prevX; private static int prevY; private static int prevX2; private static int prevY2; int pl=1; private static boolean prevValid = false; private static boolean prevValid2 = false; private int curX; private int curY; public static final double MIN_PROP = ProjectileWorld.MIN_FORCE / ProjectileWorld.MAX_FORCE; public AimDisplay(HumanPlayer player, int radius, boolean showTarget) { this.player = player; this.radius = radius; redraw(0, 0); } /** * Act - do whatever the AimDisplay wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { MouseInfo info = Greenfoot.getMouseInfo(); if (info != null) { int xDir = info.getX() - getX(); int yDir = info.getY() - getY(); if (yDir >= -1) { yDir = -1; } double angle = Math.atan2(yDir, xDir); if (angle >= -Math.toRadians(ProjectileWorld.LOWEST_ANGLE)) { angle = -Math.toRadians(ProjectileWorld.LOWEST_ANGLE); } if (angle <= -Math.toRadians(180 - ProjectileWorld.LOWEST_ANGLE)) { angle = -Math.toRadians(180 - ProjectileWorld.LOWEST_ANGLE); } double distProp = Math.hypot(xDir, yDir) / (double)radius; if (distProp > 1) { distProp = 1; } else if (distProp < MIN_PROP) { distProp = MIN_PROP; } double forceFactor = (distProp - MIN_PROP) / (1 - MIN_PROP); redraw(angle, forceFactor); if (Greenfoot.mouseClicked(null) && pl == 1) { prevX = curX; prevY = curY; prevValid = true; player.fire(angle, forceFactor); getWorld().removeObject(this); } else if (Greenfoot.mouseClicked(null) && pl == 2) { prevX2 = curX; prevY2 = curY; prevValid2 = true; player.fire(angle, forceFactor); getWorld().removeObject(this); } } } private void redraw(double radianAngle, double forceFactor) { float[] spacing = {0.0f, (float)(MIN_PROP - 0.001f), (float)MIN_PROP, 1.0f}; Color[] colors = {new Color(0.0f, 0.0f, 0.0f, 0.0f), new Color(0.0f, 0.0f, 0.0f, 0.0f), new Color(1.0f, 0.0f, 0.0f, 0.1f), new Color(1.0f, 0.0f, 0.0f, 0.5f)}; RadialGradientPaint p = new RadialGradientPaint(radius, radius, radius, spacing, colors); double dist = (MIN_PROP + (forceFactor * (1 - MIN_PROP))) * (double)radius; GreenfootImage img = new GreenfootImage(radius*2, radius*2); Graphics2D g = img.getAwtImage().createGraphics(); g.setPaint(p); g.fillArc(0, 0, radius * 2, radius * 2, ProjectileWorld.LOWEST_ANGLE, 180 - 2 * ProjectileWorld.LOWEST_ANGLE); g.dispose(); img.setColor(new Color(1.0f, 0.0f, 0.0f, 0.8f)); curX = radius + (int)(dist * Math.cos(radianAngle)); curY = radius + (int)(dist * Math.sin(radianAngle)); img.drawLine(radius, radius, curX, curY); img.drawLine(curX - 5, curY - 5, curX + 5, curY + 5); img.drawLine(curX - 5, curY + 5, curX + 5, curY - 5); if (prevValid && pl == 1) { img.setColor(new Color(0.0f, 0.0f, 1.0f, 0.8f)); img.drawLine(radius, radius, prevX, prevY); img.drawLine(prevX - 5, prevY - 5, prevX + 5, prevY + 5); img.drawLine(prevX - 5, prevY + 5, prevX + 5, prevY - 5); pl = 2; } else if (prevValid2 && pl == 2) { img.setColor(new Color(0.0f, 0.0f, 1.0f, 0.8f)); img.drawLine(radius, radius, prevX2, prevY2); img.drawLine(prevX2 - 5, prevY2 - 5, prevX2 + 5, prevY2 + 5); img.drawLine(prevX2 - 5, prevY2 + 5, prevX2 + 5, prevY2 - 5); pl = 1; } setImage(img); } } wenn man den code hier für das aimdisplay einsetzt, blinkt der vorherige vom Gegner abwechselnd mit dem eigenen vorherigen. ich hab schon versucht den vom gegner auszublenden, aber bin zu faul es fertig zu stellen :) was hier anders ist, ist dass eine zweite Vorher-Koordinate dabei ist, die immer abwechselnd beschrieben werden