Permalink
Browse files

dodany skydome w menu i w grze, fixy

  • Loading branch information...
1 parent 82341e2 commit 4686d4108ed1360ca2ab2ab03206a55a6bd3f852 @K42 committed Feb 19, 2012
View
41 Pong3Da/Pong3Da/Camera.cs
@@ -37,6 +37,7 @@ public class Camera : Microsoft.Xna.Framework.GameComponent {
private float ar;
private int k = 0;
private TimeSpan timer = TimeSpan.FromSeconds(0);
+ public bool affected { get; private set; }
protected int bonusDuration = 0;
public Camera(Game game, Vector3 pos, Vector3 target, Vector3 up, int p, Viewport view)
@@ -49,7 +50,7 @@ public Camera(Game game, Vector3 pos, Vector3 target, Vector3 up, int p, Viewpor
basespeed = 1.0f;
speedup = basespeed;
offsetDistance = new Vector3(0, 0, 85);
-
+ affected = false;
yaw = 0.0f;
pitch = 0.0f;
@@ -98,6 +99,27 @@ public Camera(Game game, Vector3 pos, Vector3 target, Vector3 up, int p, Viewpor
/// <param name="gameTime">Provides a snapshot of timing values.</param>
public override void Update(GameTime gameTime) {
+ // Recreate the camera view matrix
+ InputHandler();
+ UpdateView();
+ CreateLookAt();
+
+ //sprawdzanie bonusa
+ if (bonusDuration > 0)
+ {
+ timer += gameTime.ElapsedGameTime;
+ if (timer.TotalSeconds > bonusDuration)
+ {
+ speedup = basespeed;
+ bonusDuration = 0;
+ affected = false;
+ }
+ }
+ else timer = TimeSpan.FromSeconds(0);
+ base.Update(gameTime);
+ }
+ private void InputHandler()
+ {
KeyboardState keyboardState = Keyboard.GetState();
float speed = .02f;
@@ -148,22 +170,6 @@ public Camera(Game game, Vector3 pos, Vector3 target, Vector3 up, int p, Viewpor
k = 2;
}
}
- // Recreate the camera view matrix
- UpdateView();
- CreateLookAt();
-
- //sprawdzanie bonusa
- if (bonusDuration > 0)
- {
- timer += gameTime.ElapsedGameTime;
- if (timer.TotalSeconds > bonusDuration)
- {
- speedup = basespeed;
- bonusDuration = 0;
- }
- }
- else timer = TimeSpan.FromSeconds(0);
- base.Update(gameTime);
}
public Camera getInstance()
{
@@ -198,6 +204,7 @@ public float[] getDim()
public void PowerUp(int active, float value)
{
this.bonusDuration = active;
+ affected = true;
speedup = value;
}
}
View
39 Pong3Da/Pong3Da/Game1.cs
@@ -43,12 +43,13 @@ public class Game1 : Microsoft.Xna.Framework.Game
SpriteFont topFont;
SoundEffect menu_go, game_p_1, game_p_2, game_hit, game_point, game_win;
+ protected Camera menu_camera;
public Camera camera1 { get; protected set; }
public Camera camera2 { get; protected set; }
protected PowerUp powerUp;
private Ball ball;
private Player player1, player2;
- StaticModel sphere, aX, aY, aZ;
+ StaticModel sphere, aX, aY, aZ, skydome, menudome;
BoundingSphere playDome;
//boole pomocnicze
bool baal;
@@ -72,7 +73,7 @@ public class Game1 : Microsoft.Xna.Framework.Game
//tablica opcji w menu ekranu startowego
string[] duel_prop = { "Game type: ", "Time limit: ", "Points limit: ", "START!" };
//tekstury do menu i strzalki
- Texture2D intro_ball, logo, arrow;
+ Texture2D intro_ball, logo, arrow, bg1, bg2;
Vector2 speed;
Viewport mainViewport;
@@ -86,9 +87,9 @@ public class Game1 : Microsoft.Xna.Framework.Game
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Window.AllowUserResizing = false;
- this.graphics.IsFullScreen = false;
- this.graphics.PreferredBackBufferWidth = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * 0.75);
- this.graphics.PreferredBackBufferHeight = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * 0.75);
+ this.graphics.IsFullScreen = true;
+ this.graphics.PreferredBackBufferWidth = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width);
+ this.graphics.PreferredBackBufferHeight = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
//aspectRatio = (float)GraphicsDeviceManager.DefaultBackBufferWidth / (2 * GraphicsDeviceManager.DefaultBackBufferHeight);
}
#endregion
@@ -110,10 +111,14 @@ public class Game1 : Microsoft.Xna.Framework.Game
aX = new StaticModel(Content.Load<Model>(@"models\ring"), 0, 0, 0);
aY = new StaticModel(Content.Load<Model>(@"models\ring"), 90, 0, 0);
aZ = new StaticModel(Content.Load<Model>(@"models\ring"), 90, 90, 0);
+ skydome = new StaticModel(Content.Load<Model>(@"models\skydome"), 2.0f, 1.0f, false);
+ menudome = new StaticModel(Content.Load<Model>(@"models\skydome"), 2.0f, 1.0f, true);
playDome = new BoundingSphere(Vector3.Zero, sphere.model.Meshes[0].BoundingSphere.Radius * 1.0f);
intro_ball = Content.Load<Texture2D>(@"textures/intro_ball");
logo = Content.Load<Texture2D>(@"textures/spong");
arrow = Content.Load<Texture2D>(@"textures/arrow");
+ bg1 = Content.Load<Texture2D>(@"textures/bg1");
+ bg2 = Content.Load<Texture2D>(@"textures/bg2");
dubstep_intro = Content.Load<Song>(@"intro");
powerUp = new PowerUp(this);
menu = new MenuComponent(this, spriteBatch, Content.Load<SpriteFont>("menufont"), menuItems);
@@ -156,6 +161,7 @@ public class Game1 : Microsoft.Xna.Framework.Game
camera1 = new Camera(this, new Vector3(0, 0, 80), Vector3.Zero, Vector3.Up, 1, leftViewport);
camera2 = new Camera(this, new Vector3(0, 0, 80), Vector3.Zero, Vector3.Up, 2, rightViewport);
+ menu_camera = new Camera(this, new Vector3(0, 0, 80), Vector3.Zero, Vector3.Up, 2, mainViewport);
ball = new Ball(this);
player1 = new Player(this, 1);
@@ -532,22 +538,32 @@ protected void HandleInGameDuringRound(GameTime gameTimer)
#region Drawing
//rysowanie dodatkow menu glownego
protected void DrawMainMenu()
- {
+ {
GraphicsDevice.Clear(Color.Black);
+ menudome.Update();
+ menudome.Draw(menu_camera);
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
spriteBatch.Draw(logo, new Vector2(mainViewport.Width/2 - 167, 10), Color.White);
spriteBatch.Draw(intro_ball, new Vector2(x, y), Color.Gainsboro);
spriteBatch.End();
}
+ protected void DrawDuelPreparation()
+ {
+ menudome.Update();
+ menudome.Draw(menu_camera);
+ }
//gorny panel podczas rozgrywki
protected void TopBar()
{
spriteBatch.Begin();
- spriteBatch.DrawString(topFont, "Player 1: " + player1.pts, new Vector2(topBarViewport.X + 50, topBarViewport.Y + 10), Color.White);
+ spriteBatch.DrawString(topFont, "Player 1: " + player1.pts, new Vector2(topBarViewport.Width / 2 - 200, topBarViewport.Y + 10), Color.White);
spriteBatch.DrawString(topFont, "Player 2: " + player2.pts, new Vector2(topBarViewport.Width / 2 + 100, topBarViewport.Y + 10), Color.White);
if (powerUp.applied)
{
- spriteBatch.DrawString(topFont, "POWER UP! ", new Vector2(topBarViewport.Width - 100, topBarViewport.Y + 50), powerUp.GetFlavorColor());
+ int k = 0;
+ if (camera1.affected) k = 1;
+ else if (camera2.affected) k = 2;
+ spriteBatch.DrawString(topFont, powerUp.GetFlavorText(k), new Vector2(topBarViewport.Width - 200, topBarViewport.Y + 50), powerUp.GetFlavorColor());
}
if (gt == GameType.Time)
{
@@ -648,8 +664,10 @@ protected void DrawSplitScreenArena(Viewport left_view, Viewport right_view)
TopBar();
//prawy do lewego!!
graphics.GraphicsDevice.Viewport = left_view;
+ skydome.Draw(camera1);
ball.Draw(camera1);
powerUp.Draw(camera1);
+
//GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.BlendState = BlendState.AlphaBlend;
player1.Draw(camera1);
@@ -662,6 +680,8 @@ protected void DrawSplitScreenArena(Viewport left_view, Viewport right_view)
DrawArrow(camera1.getDirection());
graphics.GraphicsDevice.Viewport = right_view;
+
+ skydome.Draw(camera2);
ball.Draw(camera2);
powerUp.Draw(camera2);
//GraphicsDevice.BlendState = BlendState.Opaque;
@@ -683,7 +703,8 @@ protected void DrawSplitScreenArena(Viewport left_view, Viewport right_view)
graphics.GraphicsDevice.Viewport = mainViewport;
DrawMainMenu();
}
-
+ if (gs == GameState.SuitUp)
+ DrawDuelPreparation();
if (gs == GameState.InGameDuringRound)
{
DrawSplitScreenArena(leftViewport, rightViewport);
View
16 Pong3Da/Pong3Da/PowerUp.cs
@@ -135,6 +135,22 @@ public Color GetFlavorColor()
return Color.White;
return Color.Black;
}
+ public string GetFlavorText(int player)
+ {
+ if (f == flavor.green)
+ return "PLAYER " + player + "SPEED UP!";
+ if (f == flavor.blue)
+ return "CRAWLER-BALL!";
+ if (f == flavor.red)
+ {
+ if (player == 1) player = 2;
+ if (player == 2) player = 1;
+ return "PLAYER " + player + "SLOOOOOW DOOOOWN";
+ }
+ if (f == flavor.black)
+ return "BULLET TIME!";
+ return "";
+ }
//kolizje
public bool Intersect(Vector3 coords, int rad)
{
View
5 Pong3Da/Pong3Da/StaticModel.cs
@@ -14,6 +14,7 @@ class StaticModel
public Model model { get; protected set; }
protected Matrix world = Matrix.Identity;
private float rotationX = 0, rotationY = 0, rotationZ = 0, scale = 1, alpha = 0.20f;
+ bool spin = false;
public StaticModel(Model m, float rX, float rY, float rZ)
{
@@ -26,15 +27,17 @@ public StaticModel(Model m)
{
this.model = m;
}
- public StaticModel(Model m, float s, float a)
+ public StaticModel(Model m, float s, float a, bool r)
{
this.model = m;
this.alpha = a;
this.scale = s;
+ this.spin = r;
}
public virtual void Update()
{
+ if (spin) rotationY += 0.01f;
}
public void Draw(Camera camera)
View
28 Pong3Da/Pong3DaContent/Pong3DaContent.contentproj
@@ -174,6 +174,34 @@
<Processor>ModelProcessor</Processor>
</Compile>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="textures\bg1.jpg">
+ <Name>bg1</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="textures\bg2.jpg">
+ <Name>bg2</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="textures\sky.jpg">
+ <Name>sky</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="models\skydome.fbx">
+ <Name>skydome</Name>
+ <Importer>FbxImporter</Importer>
+ <Processor>ModelProcessor</Processor>
+ </Compile>
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
View
4,851 Pong3Da/Pong3DaContent/models/skydome.fbx
4,851 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN Pong3Da/Pong3DaContent/textures/bg1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Pong3Da/Pong3DaContent/textures/bg2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Pong3Da/Pong3DaContent/textures/sky.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Pong3Da/Pong3DaContent/textures/sky2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4686d41

Please sign in to comment.