Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Project_game4/.vs/Project_game4/v14/.suo
Binary file not shown.
Binary file added Project_game4/.vs/Project_game4/v15/.suo
Binary file not shown.
119 changes: 119 additions & 0 deletions Project_game4/Project_game4/Button.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Xna.Framework.Input;
using Microsoft.VisualBasic;

namespace Project_game4
{

public class Button
{
int buttonX, buttonY, buttonWidth, buttonHeigth;
string Name;
Texture2D Texture;
public bool isClicked;
public bool isHovered;
public bool isClickable;
public bool hasBeenClicked;
public bool Clicked;
Vector2 Position;
public Color Color;
SpriteFont font;



public int ButtonX
{
get
{
return buttonX;
}
}

public int ButtonY
{
get
{
return buttonY;
}
}

public Button(string name, Texture2D texture, int buttonX, int buttonY, SpriteFont font,int Width,int Height,Color color)
{
this.Name = name;
this.Texture = texture;
this.buttonX = buttonX;
this.buttonY = buttonY;
this.buttonWidth = Width;
this.buttonHeigth = Height;
this.Position = new Vector2(this.buttonX, this.buttonY);
this.font = font;
this.isClickable = true;
this.Color = color;
}

public void Update()
{
var mouseState = Mouse.GetState();

if((mouseState.X >=buttonX && mouseState.X<= (buttonX+buttonWidth)) && (mouseState.Y >= buttonY && mouseState.Y<(buttonY + buttonHeigth)))
{
this.isHovered = true;
this.Color = Color.Green;

Console.WriteLine("Hover works");


Clicked = mouseState.LeftButton == ButtonState.Pressed;

if (this.Clicked == true)
{
this.Color = Color.Green;
this.hasBeenClicked = true;

Console.WriteLine(mouseState.X);
Console.WriteLine("Clicked works");

}
if (hasBeenClicked == true)
{
//Execute Action here
Console.WriteLine("hasBeenClicked works");

}
}
else
{
this.isHovered = false;
this.Clicked = false;
this.Color = Color.Red;
}


}





public void Draw(SpriteBatch spriteBatch)
{
if (isHovered)
spriteBatch.Draw(this.Texture, this.Position, this.Color);
else
spriteBatch.Draw(this.Texture, this.Position, this.Color);


spriteBatch.Draw(Texture, Position,Color);
spriteBatch.DrawString(this.font, this.Name, new Vector2(this.buttonX + 5, this.buttonY + 7), Color.Black);

}

}
}
7 changes: 7 additions & 0 deletions Project_game4/Project_game4/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@

#---------------------------------- Content ---------------------------------#

#begin FONT.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
/processorParam:PremultiplyAlpha=True
/processorParam:TextureFormat=Compressed
/build:FONT.spritefont

60 changes: 60 additions & 0 deletions Project_game4/Project_game4/Content/FONT.spritefont
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">

<!--
Modify this string to change the font that will be imported.
-->
<FontName>Arial</FontName>

<!--
Size is a float value, measured in points. Modify this value to change
the size of the font.
-->
<Size>12</Size>

<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>

<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>

<!--
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>

<!--
If you uncomment this line, the default character will be substituted if you draw
or measure text that contains characters which were not included in the font.
-->
<!-- <DefaultCharacter>*</DefaultCharacter> -->

<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
character set. The characters are ordered according to the Unicode standard.
See the documentation for more information.
-->
<CharacterRegions>
<CharacterRegion>
<Start>&#32;</Start>
<End>&#126;</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
Binary file not shown.
9 changes: 9 additions & 0 deletions Project_game4/Project_game4/Content/obj/DesktopGL/.mgcontent
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<SourceFileCollection xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Profile>Reach</Profile>
<Platform>DesktopGL</Platform>
<Config />
<SourceFiles>
<File>C:/Users/jessi/Documents/GitHub/Project4/Project_game4/Project_game4/Content/FONT.spritefont</File>
</SourceFiles>
</SourceFileCollection>
22 changes: 22 additions & 0 deletions Project_game4/Project_game4/Content/obj/DesktopGL/FONT.mgcontent
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SourceFile>C:/Users/erikv/Desktop/Proj4/Project1/Project4-Niet-master/Project_game4/Project_game4/Content/FONT.spritefont</SourceFile>
<SourceTime>2017-06-21T06:27:00+02:00</SourceTime>
<DestFile>C:/Users/erikv/Desktop/Proj4/Project1/Project4-Niet-master/Project_game4/Project_game4/Content/bin/DesktopGL/FONT.xnb</DestFile>
<DestTime>2017-06-21T21:38:54.0117295+02:00</DestTime>
<Importer>FontDescriptionImporter</Importer>
<ImporterTime>2017-03-01T16:05:36+01:00</ImporterTime>
<Processor>FontDescriptionProcessor</Processor>
<ProcessorTime>2017-03-01T16:05:36+01:00</ProcessorTime>
<Parameters>
<Key>PremultiplyAlpha</Key>
<Value>True</Value>
</Parameters>
<Parameters>
<Key>TextureFormat</Key>
<Value>Compressed</Value>
</Parameters>
<Dependencies />
<BuildAsset />
<BuildOutput />
</PipelineBuildEvent>
48 changes: 46 additions & 2 deletions Project_game4/Project_game4/Game1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Linq;
using System;

using Microsoft.VisualBasic;

namespace Project_game4
{
Expand All @@ -11,11 +15,27 @@ public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Menu menu;
SpriteFont Font;
Texture2D rect;

int ButtonWith;
int ButtonHeight;


public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";


this.ButtonWith = 200;
this.ButtonHeight = 30;





}

/// <summary>
Expand All @@ -27,6 +47,13 @@ public Game1()
protected override void Initialize()
{
// TODO: Add your initialization logic here
graphics.IsFullScreen = false;
graphics.PreferredBackBufferWidth = Convert.ToInt32(GraphicsDevice.DisplayMode.Width * 0.9f);
graphics.PreferredBackBufferHeight = Convert.ToInt32(GraphicsDevice.DisplayMode.Height * 0.9f);
graphics.ApplyChanges();
Window.AllowUserResizing = true;
this.IsMouseVisible = true;
base.Initialize();

base.Initialize();
}
Expand All @@ -39,8 +66,16 @@ protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
Font = Content.Load<SpriteFont>("FONT");


// TODO: use this.Content to load your game content here
rect = new Texture2D(graphics.GraphicsDevice, this.ButtonWith, this.ButtonHeight);
Color[] data = new Color[this.ButtonWith * this.ButtonHeight];
for (int i = 0; i < data.Length; ++i) data[i] = Color.White;
rect.SetData(data);

menu = new Project_game4.Menu(graphics, this.rect, Font);
}

/// <summary>
Expand All @@ -61,7 +96,7 @@ protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();

menu.Update();
// TODO: Add your update logic here

base.Update(gameTime);
Expand All @@ -73,11 +108,20 @@ protected override void Update(GameTime gameTime)
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GraphicsDevice.Clear(Color.DarkOliveGreen);

spriteBatch.Begin();
menu.Draw(spriteBatch);
spriteBatch.End();
// TODO: Add your drawing code here

base.Draw(gameTime);
}
public void Quit()
{
this.Exit();
}
}


}
12 changes: 12 additions & 0 deletions Project_game4/Project_game4/Highscore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project_game4
{
class Highscore
{
}
}
17 changes: 17 additions & 0 deletions Project_game4/Project_game4/IGUIelement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Project_game4
{
interface IGUIelement
{
void Draw(SpriteBatch spritebatch);
void Update();
}
}
Loading