[Java]need quick help with applet menu

Shout-Out

User Tag List

Results 1 to 1 of 1
  1. #1
    Zantas's Avatar Contributor
    Reputation
    258
    Join Date
    Dec 2007
    Posts
    1,114
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Java]need quick help with applet

    I need to figure out why points in the following code don't update if you catch a carrot after the first spawned row of carrots.

    I also need to make it possible so that if you loose all your lives the points and level also resets to startvalues.


    Code:
    package kallekanin;
    
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Event;
    import java.awt.Font;
    import java.awt.Image;
    
    
    public class Rabbit extends java.applet.Applet implements Runnable {
    
        Font f = new Font("Comic Sans", Font.BOLD, 36);
        public static int kaninx;
        public static int knapp1;
        public static int kaniny;
        public static int Lives;
        public static int Level;
        public static int Points;
        public static int cSpeed;
        boolean menu;
        Image bildbuffer;
        Graphics bild;
        Image img;
        public static int screenX;
        public static int screenY;
        Thread Kanintrad;
        private int speed;
        private int speed2=2;
    
    
        public void init() {
            setSize(1360, 768);
            kaniny = 0;
            setBackground(Color.black);
    
        }
    
        public void start() {
            if (Kanintrad == null);
            {
                Kanintrad = new Thread(this);
                Kanintrad.start();
            }
        }
    
        public void stop() {
            if (Kanintrad != null);
            {
                Kanintrad.stop();
                Kanintrad = null;
            }
        }
    
        public boolean keyDown(Event evt, int knapptryck) {
    
            knapp1 = knapptryck;
            speed = 15;
            repaint();
            return true;
        }
         public boolean keyUp(Event evt, int knapptryck) {
    
    knapp1 = knapptryck;
    speed = 0;
            repaint();
            return false;
        }
    
        public void run() {
            Thread thisThread = Thread.currentThread();
    
            int NumOfCarrots = 10;
            int[] CarrotsX = new int[NumOfCarrots];
            int[] CarrotsY = new int[NumOfCarrots];
    
            while (1 != 2) {
    
            //Randomize each carrot's x before the game starts
            for(int z = 0;z < NumOfCarrots;z++)
            {
                int randx = ((int) (Math.random() * 1280) + 1);
                            int randy = ((int)(Math.random() *100)+1);
                          CarrotsX[z] = randx;
                          CarrotsY[z] = randy;
            }
                Lives = 20;
                Level = 1;
                while (Lives > 0) {
                    screenX = (this.getSize().width);
                    screenY = (this.getSize().height) - 70;
                    bildbuffer = createImage(screenX, screenY + 70);
                    bild = bildbuffer.getGraphics();
                    
                for (int i = 0; i < Level; i++) {
                     int reqP = 1000*Level;
     if (Points >= reqP) {
                            Level++;
                 
     }
                     //Add 1 to each carrots Y
                     for(int z = 0; z < NumOfCarrots; z++)
    
                          CarrotsY[z] = CarrotsY[z] + speed2;
    
    
    
    
                        switch (knapp1) {
    
                            case Event.LEFT:
                                kaninx = kaninx - speed;
                                repaint:
                                break;
                            case Event.RIGHT:
                                kaninx = kaninx + speed;
                                repaint:
                                break;
                        }
    
                        if (kaninx > 1300) {
                            kaninx = 1300;
                        }
                        if (kaninx < 0) {
                            kaninx = 0;
                        }
    
                        //Do it for every carrot
                        for(int z = 0;z < NumOfCarrots;z++)
                        {
                        if (CarrotsX[z] >= kaninx+50-(this.getSize().width/20)&& CarrotsX[z]+20 <= kaninx+ 50 + (this.getSize().width/20) && CarrotsY[z] == kaniny + 625){
                            Points = +1000;
                           int randx = ((int) (Math.random() *  1280) + 1);
                                          CarrotsX[z] = randx;
                                           int randy = ((int) (Math.random() *  100) + 1);
                                          CarrotsY[z] = randy;
                         
                            }
    
                        if (CarrotsY[z] > kaniny+625) {
                 Lives --;
                                        int randx = ((int) (Math.random() *  1280) + 1);
                                          CarrotsX[z] = randx;
                                           int randy = ((int) (Math.random() *  100) + 1);
                                          CarrotsY[z] = randy;
    
    
                       }
    
                        //End previous for loop
                        }
    
    
                        bild.drawImage(img, 0, 0, this);
                        bild.setColor(Color.ORANGE);
                        for (int f = 1; f < NumOfCarrots; f++) {
                       //      rand = ((int) (Math.random() * 1280) + 1);
                        //  morotX = rand;
                        bild.fillRect(CarrotsX[f], CarrotsY[f], 10, 30);
                        }
                        bild.setColor(Color.RED);
                        bild.fillRect(0, 0, screenX, 60);
                        bild.setColor(Color.BLACK);
                        bild.drawString("LEVEL:" + Level, 10, 40);
                        bild.drawString("SCORE:" + Points, 150, 40);
                        bild.drawString("Required score for next level:" + reqP, 300, 40);
                        bild.drawString("Lives left:"+ Lives, 550, 40);
                        bild.setColor(Color.blue);
                        bild.fillOval(kaninx, kaniny + 595, (this.getSize().width / 20), 80);
                        bild.setColor(Color.PINK);
                        bild.fillOval(kaninx + 10, kaniny + 662, (this.getSize().width / 20), (this.getSize().height / 40));
                        bild.setColor(Color.red);
                        bild.fillRect(kaninx + 50, kaniny + 625, (this.getSize().width / 20), (this.getSize().height / 30));
                        bild.setColor(Color.lightGray);
                        bild.fillOval(kaninx + 42, kaniny + 622, (this.getSize().width / 60), (this.getSize().height / 30));
                        bild.setColor(Color.PINK);
                        bild.fillOval(kaninx + 15, kaniny + 560, (this.getSize().width / 30), 50);
                        bild.setColor(Color.lightGray);
                        bild.fillOval(kaninx + 30, kaniny + 540, (this.getSize().width / 110), 30);
                        bild.setColor(Color.BLACK);
                        bild.fillOval(kaninx + 40, kaniny + 580, (this.getSize().width / 150), 5);
                        bild.drawLine(kaninx + 30, kaniny + 595, kaninx + 50, kaniny + 600);
    
                        try {
                            repaint();
                            thisThread.sleep(15);
                            setBackground(Color.black);
                        } catch (InterruptedException e) {
                        }
    
                    }
                    
                    }
            }
            }
        
    
        public void update(Graphics G) {
            G.drawImage(bildbuffer, 0, 0, this);
        }
    
        public void paint(Graphics G) {
            update(G);
     
    {
    
    }
        }
    }
    https://i45.tinypic.com/157df7r.jpg


    [Java]need quick help with applet

Similar Threads

  1. Quick help with chat needed...
    By fvicaria in forum WoW Memory Editing
    Replies: 1
    Last Post: 11-01-2014, 11:27 AM
  2. [Need quick help]2.4.3 with 3.1.3 (arcemu)
    By nazi1992 in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 08-01-2009, 04:41 PM
  3. Need quick help with glider!
    By T.L. Cobra in forum World of Warcraft General
    Replies: 3
    Last Post: 01-31-2007, 04:09 PM
  4. Need some help with fishing bot
    By ralphie123 in forum World of Warcraft Bots and Programs
    Replies: 3
    Last Post: 11-24-2006, 09:41 AM
  5. NEED SOME HELP with Model Editing
    By Dwarf in forum World of Warcraft Model Editing
    Replies: 4
    Last Post: 09-12-2006, 08:12 PM
All times are GMT -5. The time now is 06:42 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search