Axios-Sandbox

Axios-Sandbox Commit Details


Date:2012-07-24 20:56:00 (12 years 4 months ago)
Author:Natalie Adams
Branch:default
Commit:8de1b5b4c397
Parents: 582ddc97e151
Message:Adding Texture2D Factory Test

Changes:
Asandbox/sandbox/Game.ico
Asandbox/sandbox/Game1.cs (full)
Asandbox/sandbox/GameThumbnail.png
Asandbox/sandbox/Menus/MainMenu.cs (full)
Msandbox/sandbox/Screens/Texture2DFactTest.cs (2 diffs)

File differences

sandbox/sandbox/Game1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using GameStateManagement;
using FarseerPhysics.SamplesFramework;
using sandbox.Menus;
namespace sandbox
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public ScreenManager ScreenManager { get; set; }
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.IsFullScreen = false;
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
ConvertUnits.SetDisplayUnitToSimUnitRatio(Axios.Settings.DisplayUnitToSimUnitRatio);
ScreenManager = new ScreenManager(this);
Components.Add(ScreenManager);
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
BackgroundScreen bg = new BackgroundScreen();
ScreenManager.AddScreen(bg);
ScreenManager.AddScreen(new MainMenu());
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}
sandbox/sandbox/Menus/MainMenu.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameStateManagement;
using sandbox.Screens;
using Microsoft.Xna.Framework;
namespace sandbox.Menus
{
class MainMenu : MenuScreen
{
public MainMenu() : base("Axios Sandbox") { }
public override void Activate(bool instancePreserved)
{
base.Activate(instancePreserved);
MenuEntries.Add(new MenuEntry("Texture2D Factory Test"));
MenuEntries.Add(new MenuEntry("----"));
MenuEntries.Add(new MenuEntry("Exit"));
}
protected override void OnSelectEntry(int entryIndex, PlayerIndex playerIndex)
{
base.OnSelectEntry(entryIndex, playerIndex);
switch (entryIndex)
{
case 0:
this.ScreenManager.AddScreen(new Texture2DFactTest(), PlayerIndex.One);
break;
case 2:
this.ScreenManager.Game.Exit();
break;
}
}
protected override void OnCancel(PlayerIndex playerIndex)
{
base.OnCancel(playerIndex);
ScreenManager.Game.Exit();
}
}
}
sandbox/sandbox/Screens/Texture2DFactTest.cs
1212
1313
1414
15
15
16
1617
1718
1819
......
2425
2526
2627
27
28
29
2830
2931
3032
3133
3234
3335
34
36
3537
3638
3739
40
41
42
43
3844
3945
4046
class Texture2DFactTest : AxiosGameScreen
{
private Texture2D town_tile;
private Texture2D drawme;
private Texture2D drawme_1;
private Texture2D drawme_2;
public override void Activate(bool instancePreserved)
{
base.Activate(instancePreserved);
list_of_tiles.Add(town_tile);
}
drawme = Texture2DFactory.CreateFromList(list_of_tiles, 80, 80);
drawme_1 = Texture2DFactory.CreateFromList(list_of_tiles, 160, 16);
drawme_2 = Texture2DFactory.CreateFromList(list_of_tiles, 80, 80);
}
public override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);
ScreenManager.SpriteBatch.Draw(drawme, Vector2.Zero,
ScreenManager.SpriteBatch.Draw(drawme_1, new Vector2(-30, -30),
null,
Color.White, 0, Vector2.Zero, 1f,
SpriteEffects.None, 0f);
ScreenManager.SpriteBatch.Draw(drawme_2, Vector2.Zero,
null,
Color.White, 0, Vector2.Zero, 1f,
SpriteEffects.None, 0f);
ScreenManager.SpriteBatch.End();
}
}

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.44029s using 14 queries.