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

📄 game.java

📁 一款模拟飞行类游戏的Java源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     public void createSpark(int x, int y)      {         addVisual(new Explosion(c_spark_color_table, x, y, (byte)6, 4000, 6000));     }          public void createDirectionSpark(int x, int y, int angle, int dispersion)      {         addVisual(new Explosion(c_spark_color_table, x, y, (byte)6, 4000, 6000, angle, dispersion, (byte)-1, (byte)-1));     }     public void createControlledSpark(int x, int y, int angle, int angle_dispersion, byte speed, byte speed_dispersion)     {         addVisual(new Explosion(c_spark_color_table, x, y, (byte)6, 4000, 6000, angle, angle_dispersion, speed, speed_dispersion));     }               public void createSplash(byte type, int x, int y, byte particles, byte xspeed, byte yspeed, byte x_speed_add)      {           switch(type)           {               case WATER: addVisual(new Splash(x, y, (byte)particles, (byte)3, 40000, xspeed, yspeed, x_speed_add, c_water_table)); break;               case GROUND: addVisual(new Splash(x, y, (byte)particles, (byte)3, 40000, xspeed, yspeed, x_speed_add, c_ground_table)); break;               case TREE: addVisual(new Splash(x, y, (byte)particles, (byte)3, 40000, xspeed, yspeed, x_speed_add, c_ground_table)); break;           }     }          public int getScore()     {         return m_score;     }          public Plane createPlane(int type, int x, int y, int angle, int speed)     {         // int turn_rate, int fire_rate, int engine_power, int mass         int idx = type * 5;         Plane p = new Plane(this, m_resource_manager.getPlane(0), m_resource_manager.getPlane(1),                                   m_plane_info[idx + 0], m_plane_info[idx + 1],                                    m_plane_info[idx + 2], m_plane_info[idx + 3], m_plane_info[idx + 4]);         p.setPoint(x, y);         p.setSpeed(speed);         p.setAngle(angle);         addObject(p);         return p;     }     public AIPlane createAIPlane(int type, int x, int y, int angle, int speed)    {        int idx = type * 5;        AIPlane p = new AIPlane(this, m_resource_manager.getPlane(2), m_resource_manager.getPlane(3),                   m_plane_info[idx + 0], m_plane_info[idx + 1],                    m_plane_info[idx + 2], m_plane_info[idx + 3], m_plane_info[idx + 4]);         p.setPoint(x, y);         p.setSpeed(speed);         p.setAngle(angle);         addObject(p);         return p;    }                    public Drawable getPlaneDrawable(int index)    {        return m_resource_manager.getPlane(index);    }               public void createFlakSmoke(int x, int y, int radius)      {        addVisual(new FlakSmoke(x, y, radius));     }               public void createBullet(int x, int y, int vx, int vy, int existance, int blast)      {                addObject(new Bullet(this, x, y, vx, vy, existance, blast));     }          public Building createBuilding(int type, int x, byte hitpoints)      {            Building b = new Building(this, m_resource_manager.getBuilding(type), Common.toFP(x), hitpoints);            addObject(b);            return b;     }               public void event(byte type, boolean pressed)     {         m_game_handler.event(type, pressed);     }     public boolean isQuit()     {         return m_quit;     }          public ResourceManager getResourceManager()     {         return m_resource_manager;     }          public int getHeight()     {         return m_full_height;     }          public int getWidth()     {         return m_full_width;     }          public void resetScreenOptions()     {            m_view_start_height = 0;            m_view_height = m_full_height;      }          public void setScreenOptions(int start, int height)     {        m_view_start_height = start;        m_view_height = height;     }          public void resetClip(Graphics g)     {         g.setClip(0, m_view_start_height, m_full_width, m_view_height);     }                    public void enableHandling()     {         m_handling = true;     }          public void disableHandling()     {         m_handling = false;     }          public void destruct()     {        m_objects.removeAllElements();        m_visual.removeAllElements();        m_objects = null;        m_visual = null;         if (m_terrain != null) m_terrain.destruct();        m_terrain = null;        m_targets = null;          m_resource_manager = null;        m_game_handler = null;     }          public Storage getStorage()     {         return m_resource_manager.getStorage();     }          public Tree createTree(byte index, int pos_x)     {        Tree ret_val = new Tree(this, m_resource_manager.getTree(index), pos_x);        addObject(ret_val);        return ret_val;     }     public Tank createTank(byte index, int pos_x)     {        Tank ret_val = new Tank(this, m_resource_manager.getTank(index), pos_x);        addObject(ret_val);        return ret_val;     }               public Tank createSubmarine(int x, int y)     {        Tank ret_val = new Tank(this, m_resource_manager.getSubmarine(), x, y);        addObject(ret_val);        return ret_val;     }                   public Zeppelin createZeppelin(int x, int y, int speed_x, int hitpoints)     {        Zeppelin ret_val = new Zeppelin(this, m_resource_manager.getZeppelin(), x, y, speed_x, hitpoints);        addObject(ret_val);        return ret_val;     }          public Cloud createCloud(byte type, int x, int y, int vx)     {         Cloud ret_val = new Cloud(this, m_resource_manager.getCloud(type), x, y, vx);         addVisual(ret_val);         return ret_val;     }               public boolean isSpecialState(byte type)     {        return m_special_state[type] > 0;     }          public void setSpecialState(byte type)     {         if (m_special_state[type] == 0) m_special_state[type] = 1;     }         public void clearSpecialState(byte type)     {         if (m_special_state[type] == 1) m_special_state[type] = 0;     }               public void disableSpecialState(byte type)     {          m_special_state[type] = -1;     }          public String getLevelName()     {                  return m_level_name;     }          public byte getDifficultyLevel()     {         return (byte)Math.min(m_level + 1 + m_difficulty_setting * 2, (byte)10);     }          public String getSpecialStateName(byte type)     {         return Str.special_states[type];     }                    public boolean isTarget(GameObject go)     {         if (m_targets == null) return false;                for (int i = 0; i < m_targets.length; i++)        {            if (m_targets[i] == go) return true;        }        return false;     }     // =========================================================================;//	Name:	void checkSpecialEnd()//	Desc:	checks which special states can actually be won on this //              level     // ==========================================================================;     protected void checkSpecialStateStart()     {        if (m_targets == null || m_targets.length == 0) disableSpecialState(SURGICAL_STRIKE);        boolean devastator = false;        boolean lumberjack = false;        boolean tankbuster = false;         boolean surgical_strike = false;                 for (int i = 0; i < getObjectSize(); i++)        {            GameObject go = getGameObject(i);            if (go.getObjectType() == GameObject.BUILDING && isTarget(go) == false)             {                devastator = true;                surgical_strike = true;            }            if (go.getObjectType() == GameObject.TREE && isTarget(go) == false) lumberjack = true;            if (go.getObjectType() == GameObject.TANK && isTarget(go) == false)             {                tankbuster = true;                surgical_strike = true;            }        }                if (devastator == false) disableSpecialState(DEVASTATOR);        if (lumberjack == false) disableSpecialState(LUMBERJACK);        if (tankbuster == false) disableSpecialState(TANK_BUSTER);        if (surgical_strike == false) disableSpecialState(SURGICAL_STRIKE);        else setSpecialState(SURGICAL_STRIKE);     }    // =========================================================================;//	Name:	void checkSpecialStateEnd()//	Desc:	checks which states have been acheived// ==========================================================================;     protected void checkSpecialStateEnd()     {        boolean devastator = true;        boolean lumberjack = true;        boolean tankbuster = true;                 for (int i = 0; i < getObjectSize(); i++)        {            GameObject go = getGameObject(i);            if (go.isAlive() == false) continue;            if (go.getObjectType() == GameObject.BUILDING) devastator = false;            else if (go.getObjectType() == GameObject.TANK) tankbuster = false;            else if (go.getObjectType() == GameObject.TREE) lumberjack = false;        }                if (devastator) setSpecialState(DEVASTATOR);        if (lumberjack) setSpecialState(LUMBERJACK);        if (tankbuster) setSpecialState(TANK_BUSTER);     }               public int getSpecialStateScore(byte type)     {         switch(type)         {             case KAMIKAZE:             return 100;             case BOMBER:               return 10;             case GUNNER:               return 50;             case SURGICAL_STRIKE:      return 100;             case DEVASTATOR:           return 50;             case LUMBERJACK:           return 10;             case GOLD_MEDAL:           return 100;             case TANK_BUSTER:          return 50;             case CON_MAN:              return 200;             case IRON_MAN:             return 25;             case ACE:                  return 20;             default:                   return 0;         }     }               public int getLeftBound()     {         return Common.toFP(m_bound_left);     }          public int getRightBound()     {         return Common.toFP(m_bound_right);     }               public int getTopBound()     {         return Common.toFP(m_bound_top);     }          public void disableLookahead()     {         m_is_lookahead = false;     }          public void enableLookahead()     {         m_is_lookahead = true;     }          public void setHandleSpeed(int factor)     {         m_handle_speed_factor = factor;     }          public short[] getMissionData()     {         return m_mission_data;     }          public void setMissionData(short[] data)     {         m_mission_data = data;     }           }

⌨️ 快捷键说明

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