» 您尚未登录:请 登录 | 注册 | 标签 | 帮助 | 小黑屋 |


 28 12
发新话题
打印

PS3,XO// [BURNOUT 5] 首批画面公布~~~~

引用:
原帖由 ffcactus 于 2007-4-4 13:01 发表
对于你这种低级趣味的把戏,一下问你这懂吗?一下问你那有吗?很多人已经表演过无数次了.


就凭你几句
PS3游戏开发中调用过程需要用汇编, 和编写汇编就是"编译"一下.
我已经很清楚您的水准了.
多说也没什么意义.
你别恶心了,我什么时候说过编写汇编就是"编译以下",你自己YY的吗?


TOP

#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace LLK
{
  public class Game1 : Microsoft.Xna.Framework.Game
  {
      

      #region 按键处理
      bool isMouseLeftUp = true;
      bool isAltEnterUp = true;
      bool isF5Up=true;
      bool isF6Up=true;
      bool isF7Up=true;
      bool isF12Up = true;
      KeyboardState keyState;
      MouseState current_mouse;
      #endregion

      #region 常量定义
      private const int blockWidth = 40;
      private const int blockHeight = 50;
      #endregion

      #region 绘图区
      private GraphicsDeviceManager graphics;
      public static ContentManager content;
      
      
      
      private SpriteBatch forceBatch;
      
      private Texture2D sprSprite;
      private Texture2D mouseSprite;
      private Texture2D bgSprite;
      private Texture2D menuSprite;
      private Texture2D selhardSprite;
      private Texture2D partSprite;
      private Texture2D overSprite;
      #endregion

      #region 游戏数据,状态
      private Map map;
      private Vector2 m_Mouse;
      private GameState gamestate;
      private Level level;
      private int menuSel=-1;
      private Rectangle menuRect;

      private Rectangle sourceRect;
      private Vector2 destVec;

      private Vector2 pauseVector;
      private Rectangle pauseRect;
      private Vector2 numVector;
      private Rectangle numRect;
      private Vector2 hardVector;
      private Rectangle hardRect;
      private Vector2 levelVector;
      private Rectangle levelRect;
      private Vector2 lineVector;
      private Rectangle lineRect;
      private Rectangle selRect;
      private Vector2 nextLevelVector;
      private Rectangle nextLevelRect;
      private Vector2 leftTimeVector;
      private Rectangle leftTimeRect;
      private Rectangle bgRect;
      private Vector2 overVector;
      private Rectangle overRect;
      private Vector2 wpVector;
      private Rectangle wpRect;
      #endregion

      #region 构造函数
      public Game1()
      {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);
            this.graphics.PreferredBackBufferHeight = 600;
            this.graphics.PreferredBackBufferWidth = 800;
            this.Window.Title = "连连看-中国XNA开发网www.xnadev.cn";
            Mouse.WindowHandle = Window.Handle;
            this.graphics.ApplyChanges();
            Sound.initSound();
            menuRect = new Rectangle(0, 0,250, 100);
            gamestate = GameState.gameResest;
            pauseRect = new Rectangle(212,129,459,417);
            pauseVector = new Vector2(180, 120);
            sourceRect = new Rectangle(0, 0, 45, 56);
            destVec = Vector2.Zero;
         
            numVector = new Vector2(0, 15);
            numRect = new Rectangle(0,102,16,21);
         
            hardVector = new Vector2(20, 15);
            hardRect = new Rectangle(0,34,110,25);
         
            levelVector = new Vector2(140,38);
            levelRect = new Rectangle(0, 0, 96, 32);

            lineVector = new Vector2(0, 0);
            lineRect = new Rectangle(0, 0, 40, 50);
            selRect = new Rectangle(680, 0, 40, 50);
            nextLevelVector = new Vector2(235, 500);
            nextLevelRect = new Rectangle(0, 540, 360, 60);
            leftTimeVector = new Vector2(239, 42);
            leftTimeRect = new Rectangle(113, 69, 363, 20);
            overVector = new Vector2(172,185);
            overRect = new Rectangle(0,0,462,265);
            wpVector = new Vector2(642, 42);
            wpRect = new Rectangle(482,0,155,26);
        }
      #endregion

      #region 主程序初始化
        protected override void Initialize()
        {
            base.Initialize();
        }

        #endregion

      #region 加载游戏资源
        protected override void LoadGraphicsContent(bool loadAllContent)
        {
            if (loadAllContent)
            {
                forceBatch = new SpriteBatch(graphics.GraphicsDevice);
                sprSprite = content.Load<Texture2D>(@"Images\spr");
                mouseSprite = content.Load<Texture2D>(@"Images\mouse");
                bgSprite = content.Load<Texture2D>(@"Images\bg");
                menuSprite = content.Load<Texture2D>(@"Images\menu");
                selhardSprite = content.Load<Texture2D>(@"Images\selhard");
                partSprite = content.Load<Texture2D>(@"Images\part");
                overSprite = content.Load<Texture2D>(@"Images\gameover");
            }
        }
        #endregion

      #region 卸载游戏资源
        protected override void UnloadGraphicsContent(bool unloadAllContent)
        {
            if (unloadAllContent == true)
            {
                content.Unload();
            }
        }
        #endregion

      #region 初始化关卡
        private void initLevel()
      {
          switch (menuSel)
          {
              case  0:
                  level = new Level(levelHard.Easy);
                  break;
              case 1:
                  level = new Level(levelHard.Normal);
                  break;
              case 2:
                  level = new Level(levelHard.Hard);
                  break;
              default:
                  return;
          }
          map = new Map(level.Width, level.Height, level.Num);
          bgRect = new Rectangle(level.Left+40,level.Top+50,5+level.Width*40,6+level.Height*50);
      }
        #endregion

      #region Update主程序
      protected override void Update(GameTime gameTime)
        {
            if (!this.IsActive)
                return;
            updateKey();
            updateMouse();
            Sound.m_AudioEngine.Update();
            switch (gamestate)
            {
                case GameState.gameResest:
                    gamestate = GameState.gameMenu;
                    break;
                case GameState.gameMenu:
                    MouseInMenu();
                    keyInMenu();
                    break;
                case GameState.gameLogin:
                    initLevel();
                    gamestate = GameState.gameRun;
                    break;
                case GameState.gameRun:
                    keyInRun();
                    mouseInRun();
                    map.update();
                    wpRect.Y = 57 + map.wuPinID * 63;
                    if (map.leftBlock == 0&&map.selnum==0)
                    {
                        if (map.Level < 10)
                            gamestate = GameState.gamePassLevel;
                        else
                            gamestate = GameState.gameOver;
                    }
                    if (map.timeLeft < 0.1f)
                    {
                        gamestate = GameState.gameOver;
                        Sound.Play("Failur");
                    }

                    break;
                case GameState.gamePassLevel:
                    if (keyState.IsKeyDown(Keys.Space))
                        gamestate = GameState.gameNextLevel;
                    break;
                case GameState.gameNextLevel:
                    map.NextLevel();
                    gamestate = GameState.gameRun;
                    break;
                case GameState.gamePause:
                    KeyInPause();
                    break;
                case GameState.gameOver:
                    break;

            }
            base.Update(gameTime);
        }
      #endregion

        #region DRAW主程序
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            switch (gamestate)
            {
                case GameState.gameResest:
                    break;
                case GameState.gameMenu:
                    gameMenu();
                    break;
                case GameState.gameLogin:
                    break;
                case GameState.gameRun:
                    gameRun();
                    break;
                case GameState.gamePassLevel:
                    gamePassLevel();
                    break;
                case GameState.gameNextLevel:
                    break;
                case GameState.gamePause:
                    gamePause();
                    break;
                case GameState.gameOver:
                    gameOver();
                    break;

            }

            base.Draw(gameTime);
        }
        private void gameMenu()
        {
            forceBatch.Begin(SpriteBlendMode.AlphaBlend);
            forceBatch.Draw(menuSprite, Vector2.Zero, Color.White);
            if (menuSel != -1)
                forceBatch.Draw(selhardSprite, destVec, menuRect, Color.White);
            forceBatch.Draw(mouseSprite, m_Mouse, Color.White);
            forceBatch.End();
        }
        #endregion

      #region 公共鼠标处理程序
      private void updateMouse()
      {
          current_mouse = Mouse.GetState();
          m_Mouse.X = current_mouse.X;
          m_Mouse.Y = current_mouse.Y;
      }
      #endregion

      #region 公共按键处理程序
      private void updateKey()
      {
          keyState = Keyboard.GetState();
          //退出游戏
          if (keyState.IsKeyDown(Keys.Escape))
              this.Exit();
          //全屏切换
          if (keyState.IsKeyDown(Keys.RightAlt) && keyState.IsKeyDown(Keys.Enter) && isAltEnterUp == true)
          {
              this.graphics.ToggleFullScreen();
              isAltEnterUp = false;
          }
          if (keyState.IsKeyUp(Keys.Enter) && isAltEnterUp == false)
              isAltEnterUp = true;
          //退回主菜单
          if (keyState.IsKeyDown(Keys.F12) && isF12Up == true)
          {
              gamestate = GameState.gameResest;
              isF12Up = false;
          }
          if (keyState.IsKeyUp(Keys.F12) && isF12Up == false)
              isF12Up = true;
      }
      #endregion

      #region 正常运行时的按键处理程序
      protected void keyInRun()
      {
         
          //提示功能
          if (keyState.IsKeyDown(Keys.F5) && isF5Up == true)
          {
              if (map.prompt != 0)
              {
                  if (map.hasSearched == 2)
                  {
                      map.hasSearched = 3;
                  }
                  --map.prompt;
              }
              isF5Up = false;
          }
          if (keyState.IsKeyUp(Keys.F5) && isF5Up == false)
              isF5Up = true;

          //重新洗牌
          if (keyState.IsKeyDown(Keys.F6) && isF6Up == true)
          {
              if (map.life != 0)
              {
                  map.RenMap();
                  --map.life;
              }
              isF6Up = false;
          }
          if (keyState.IsKeyUp(Keys.F6) && isF6Up == false)
              isF6Up = true;

          //暂停
          if (keyState.IsKeyDown(Keys.F7) && isF7Up == true)
          {
              gamestate = GameState.gamePause;
              isF7Up = false;
          }
          if (keyState.IsKeyUp(Keys.F7) && isF7Up == false)
              isF7Up = true;
         
         
      }
        #endregion

      #region 暂停状态下按键的处理
      protected void KeyInPause()
      {
          KeyboardState keyState;
          keyState = Keyboard.GetState();
          if (keyState.IsKeyDown(Keys.F7) && isF7Up == true)
          {
              gamestate = GameState.gameRun;
              isF7Up = false;
          }
          if (keyState.IsKeyUp(Keys.F7) && isF7Up == false)
              isF7Up = true;

      }
      #endregion

      #region 正常运行时的鼠标独处理程序
      protected void mouseInRun()
      {
          MouseState current_mouse = Mouse.GetState();

          m_Mouse.X = current_mouse.X;
          m_Mouse.Y = current_mouse.Y;
          if (gamestate == GameState.gameRun)
          {
              if (isMouseLeftUp && current_mouse.LeftButton == ButtonState.Pressed)
              {
                  map.mouseClick((int)m_Mouse.X - level.Left, (int)m_Mouse.Y - level.Top);
                  isMouseLeftUp = false;
              }
              if (isMouseLeftUp == false && current_mouse.LeftButton == ButtonState.Released)
              {
                  isMouseLeftUp = true;
              }
          }
          if (current_mouse.RightButton == ButtonState.Pressed)
          {
              map.selnum = 0;
          }

      }
      #endregion

      #region 菜单中处理按键
      protected void keyInMenu()
      {
          int backSel = menuSel;
          menuSel = -1;
         if (keyState.IsKeyDown(Keys.F1))
              menuSel = 0;
          if (keyState.IsKeyDown(Keys.F2))
              menuSel = 1;
          if (keyState.IsKeyDown(Keys.F3))
              menuSel = 2;
          if(menuSel!=-1)
              gamestate = GameState.gameLogin;
          else
            menuSel = backSel;
      }
      #endregion

      #region 菜单中处理鼠标
      protected void MouseInMenu()
      {
          if (m_Mouse.X > 68 && m_Mouse.Y > 134 && m_Mouse.X < 288 && m_Mouse.Y < 431)
          {
              if (m_Mouse.Y < 210)
              {
                  destVec.X = 65;
                  destVec.Y= 139;
                  menuRect.Y = 18;
                  menuSel = 0;
              }
              else if (m_Mouse.Y < 246)
              {
                  menuRect.Y = 400;
                  menuSel = -1;
              }
              else if (m_Mouse.Y < 308)
              {
                  destVec.X = 65;
                  destVec.Y = 246;
                  menuRect.Y = 125;
                  menuSel = 1;
              }
              else if (m_Mouse.Y < 365)
              {
                  menuRect.Y = 400;
                  menuSel = -1;
              }
              else
              {
                  destVec.X = 65;
                  destVec.Y = 366;
                  menuRect.Y = 245;
                  menuSel = 2;
              }
          }
          else
          {
              menuSel = -1;
          }
          if(menuSel!=-1)
          {
              if (isMouseLeftUp && current_mouse.LeftButton == ButtonState.Pressed)
              {
                  gamestate = GameState.gameLogin;
                  isMouseLeftUp = false;
              }
              if (isMouseLeftUp == false && current_mouse.LeftButton == ButtonState.Released)
              {
                  isMouseLeftUp = true;
              }
          }


      }
      #endregion
      private void DrawTitle()
      {
          forceBatch.Draw(bgSprite, Vector2.Zero, Color.White);

          hardRect.X = menuSel * 110;
          forceBatch.Draw(partSprite, hardVector, hardRect, Color.White);

          levelRect.Y = 140 + 35 * map.Level;
          forceBatch.Draw(partSprite, levelVector, levelRect, Color.White);
         
          //显示游戏中的数字
          showNumber(map.Level, 219);
          showNumber(map.prompt, 364);
          showNumber(map.life, 527);
          showNumber(map.Score, 757);
         
          leftTimeRect.Width = (int)map.timeLeft;
          forceBatch.Draw(partSprite, leftTimeVector, leftTimeRect, Color.White);
          if (gamestate != GameState.gamePause)
          {
              forceBatch.Draw(overSprite, wpVector, wpRect, Color.White);
              forceBatch.Draw(map.bgSpr, bgRect, Color.White);
          }
      }
      #region DRAW下一关
      private void gamePassLevel()
      {
          forceBatch.Begin(SpriteBlendMode.AlphaBlend);

          DrawTitle();
          forceBatch.Draw(partSprite, nextLevelVector, nextLevelRect, Color.White);
          forceBatch.End();
      }
      #endregion

      private void gameOver()
      {
          forceBatch.Begin(SpriteBlendMode.AlphaBlend);
          DrawTitle();
          DrawBlock(false);
          if (map.timeLeft < 0.1f)
              overRect.Y = overRect.Height;
          else
              overRect.Y = 0;
          forceBatch.Draw(overSprite, overVector, overRect, Color.White);
          forceBatch.Draw(mouseSprite, m_Mouse, Color.White);
          forceBatch.End();
      }

      #region 游戏暂停状态
      private void gamePause()
      {
          forceBatch.Begin(SpriteBlendMode.AlphaBlend);
          DrawTitle();
          forceBatch.Draw(partSprite, pauseVector, pauseRect, Color.White);         
          forceBatch.End();
      }
      #endregion

      #region 游戏运行时的DRAW
      private void gameRun()
      {
          forceBatch.Begin(SpriteBlendMode.AlphaBlend);
          DrawTitle();
          DrawBlock(true);
          if (map.selnum == 2)
          {
              int pos = map.sel2;
              do
              {
                  lineVector.X = level.Left + (pos % map.Width) * blockWidth;
                  lineVector.Y = level.Top + (pos / map.Width) * blockHeight;
                  if (map.line[pos] == 0 || map.line[pos] == 3)
                      lineRect.X = 760;
                  else
                      lineRect.X = 720;
                  switch (map.line[pos])
                  {
                      case 0:
                          lineVector.Y += 25;
                          break;
                      case 1:
                          lineVector.X += 20;
                          break;
                      case 2:
                          lineVector.X -= 20;
                          break;
                      case 3:
                          lineVector.Y -= 25;
                          break;
                  }
                  forceBatch.Draw(partSprite, lineVector, lineRect, Color.White);
                  pos = map.next(pos, 3 - map.line[pos]);
              } while (pos != map.sel1);
          }
          forceBatch.Draw(mouseSprite, m_Mouse, Color.White);
          forceBatch.End();
      }
      #endregion
      private void DrawBlock(bool isShowSel)
      {
          for (int i = 1; i < map.Height - 1; ++i)
          {

              destVec.Y = blockHeight * i + level.Top;
              for (int j = 1; j < map.Width - 1; ++j)
              {
                  if (map[i * map.Width + j] != -1)
                  {
                      destVec.X = blockWidth * j + level.Left;
                      sourceRect.X = map[i * map.Width + j] % 9 * sourceRect.Width;
                      sourceRect.Y = map[i * map.Width + j] / 9 * sourceRect.Height;
                      if (isShowSel)
                      {
                          if (map.hasSearched == 3)
                          {
                              if (map.search1 == i * map.Width + j || map.search2 == i * map.Width + j)
                                  sourceRect.Y += sourceRect.Height * 4;
                          }
                          else if (map.selnum != 0)
                          {
                              if (map.sel1 == i * map.Width + j)
                                  sourceRect.Y += sourceRect.Height * 4;
                              else if (map.selnum == 2 && map.sel2 == i * map.Width + j)
                                  sourceRect.Y += sourceRect.Height * 4;
                          }
                      }
                      forceBatch.Draw(sprSprite, destVec, sourceRect, Color.White);
                      if (isShowSel)
                      {
                          if (map.hasSearched == 3)
                          {
                              if (map.search1 == i * map.Width + j || map.search2 == i * map.Width + j)
                                  forceBatch.Draw(partSprite, destVec, selRect, Color.White);
                          }
                          else if (map.selnum != 0)
                          {
                              if (map.sel1 == i * map.Width + j)
                                  forceBatch.Draw(partSprite, destVec, selRect, Color.White);
                              else if (map.selnum == 2 && map.sel2 == i * map.Width + j)
                                  forceBatch.Draw(partSprite, destVec, selRect, Color.White);
                          }
                      }

                  }
              }
          }
      }

      #region 显示游戏中的数字
      private void showNumber(int num,int x)
      {
          int n;
          numVector.X = x;
          n = num;
          do
          {
              numRect.X = (n % 10) * 16;
              forceBatch.Draw(partSprite, numVector, numRect, Color.White);
              numVector.X -= 16;
              n /= 10;
          } while (n != 0);
      }
      #endregion
     
  }
   
  #region 游戏状态
  public enum GameState
    {
        gameResest,
        gameMenu,
        gameLogin,
        gameRun,
        gameNextLevel,
        gamePause,
        gameOver,
        gamePassLevel
    }
  #endregion
}

送你一个windows小游戏,你可以学习里面的函数,看看调用是怎么回事。



TOP

如果你连编译提取下级代码也不懂,然后硬要说别人说低级语言就是从高级语言提取出来的。

要么是你连小学语文也不懂,要么就是智力问题,希望不是后者:D :D


TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:13 发表


你想告诉我们什么?
想告诉我们PS3游戏的开发比这还要困难,因为要用汇编去调用,而不只是使用 FUNC(x)吗?
还是想告诉我们,写汇编就是先写C,然后在调试的时候,查看汇编代码,然后看看调用过程是怎么进出堆栈, ...
你以为开发游戏没有汇编程序员?

按照你这么说,那这10%的精英程序员都可以被解雇了,你说呢?:D :D


我还是那句话,一丁点都不懂的可以像你这样死皮赖脸的胡搅蛮缠,需要勇气:D :D

TOP

如果游戏开发仅仅是用api,而不面对底层的话,开发不出好游戏,明白?

TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:23 发表


所以PS3游戏的开发,调用某一功能就要用汇编?
你到底是要说PS3游戏开发是难还是容易呢?

你一方面说PS3开发环境不好,写个调用要用汇编.
一方面又说"如果游戏开发仅仅是用api,而不面对底层的话,开发不出 ...
俨然我并没有说所有功能都需要汇编,但某些调用的确是程序员自己用汇编写的。

比如网络。莫非你以为索尼提供的kit库函数完整,功能完备,程序员自身愚笨所以觉得难么?

TOP

引用:
原帖由 carnon 于 2007-4-4 13:24 发表
神啊,竟然在此贴看到c++ c#,期待一下某楼能出现真正的ASM程序,最好还是powerPC指令集的:D
俨然提供的都是游戏代码,你期待什么呢:D

TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:29 发表






ps,后来他说可以提取汇编代码.
你在期待别人来救你啊,不如你慢慢等等看,谁来趟这浑水:D :D

TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:30 发表


没有问你过了没有,C++代码高手.
很可惜,计算机2级证书只对应非计算机专业的,我是不需要考得:D

TOP

继续挣扎吧,让我们再爽爽:D :D

TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:37 发表


==============
别忘了,你当初是这么说的.

大家看了你这话以后,要理解成:
"我是想告诉大家,PS3游戏开发,某些东西还是要调用汇编的,只有能够接触底层,才能更有效果"
我说对吗?
你喷得可真是左右 ...
如果你学过小学语文,就应该知道我说的调用个东西并没有指明全部的东西,你计算机知识没有,难道连语文都不会吗?

TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:46 发表


既然是PS3的开发环境是你所谓的差的典型
那么起码有30%的需要用汇编吧.
会是这样的吗?
你有何证据,你这样的假设符合常理吗?
你开始自我高潮了啊:D

TOP

引用:
原帖由 ffcactus 于 2007-4-4 13:49 发表


你又准备转移话题吗?
我已经有点累于和你玩这种毫无意义的持久战了,你倒下一次还要再爬起来无数次,抱着视死如归,白死人不偿命的坚定决心,就是卡马克看到你也得怕的呀

别人说PS3代码要全负载的话要切割代码对每个SPU都有编译,你肯定要说,那么IBM的深蓝有数万颗CPU,别人为什么没有这么麻烦。

十万个为什么永远没有底,如果你想自我高潮的话请便,你已经和B神不相伯仲鸟。

对于我来说,多写几行代码,多看会MSDN比多蹂躏你更有意于身心健康,你说呢?:D

TOP

 28 12
发新话题
     
官方公众号及微博