⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hospitalevent.java

📁 关于j2me的宠物游戏!!!!!!!!!!! 希望打架提出意见
💻 JAVA
字号:
/*
 * HospitalEvent.java
 *
 * Created on 2006年5月5日, 上午11:28
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package DogPet;


import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.*;

// Referenced classes of package com.webineti:
//            GameData, GameView

public class HospitalEvent
{
    class Task10 extends TimerTask
    {

        public final void run()
        {
            if(GameView.events == 3)
            {
                swapped = swapped + 1;
                if(swapped > seedoctor.length - 1)
                {
                    swapped = 0;
                    repeat++;
                    if(repeat > 2)
                    {
                        GameView.events = -1;
                        repeat = 0;
                    }
                }
                view.repaint();
            }
        }

        Task10()
        {
        }
    }


    public void add_data()
    {
        if(GameData.Health <= 50)
            GameData.Health = 50;
        GameData.Mood -= 5;
        if(GameData.Mood < 0)
            GameData.Mood = 0;
        GameData.Capacity += 5;
        if(GameData.Capacity > 100)
            GameData.Capacity = 100;
        GameData.Weight--;
        if(GameData.Weight < 0)
            GameData.Weight = 0;
    }

    public HospitalEvent(GameView view)
    {
        repeat = 0;
        start_x = 0;
        start_y = 0;
        swapped = 0;
        image_bg = null;
        timer = new Timer();
        flashDuration = 1000;
        seedoctor = new Image[2];
        this.view = view;
        try
        {
            image_bg = Image.createImage("/hospital.png");
        }
        catch(Exception ex) { }
        try
        {
            seedoctor[0] = Image.createImage("/sick/dog_seedoctor1.png");
            seedoctor[1] = Image.createImage("/sick/dog_seedoctor2.png");
        }
        catch(Exception ex) { }
        timer.scheduleAtFixedRate(new Task10(), 0L, flashDuration);
    }

    public void paint(Graphics g)
    {
        this.g = g;
        if(seedoctor[swapped] != null)
        {
            view.g_cls(g, 0, image_bg);
            g.drawImage(seedoctor[swapped], GameData.start_x + 27, GameData.start_y + 62, 20);
        }
    }

    public void killed()
    {
        timer.cancel();
        timer = null;
    }

    GameView view;
    private Graphics g;
    int repeat;
    private int start_x;
    private int start_y;
    int swapped;
    private Image image_bg;
    private Timer timer;
    private int flashDuration;
    Image seedoctor[];
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -