Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f652cd9
SKY IS WHITE
lyshuga Oct 10, 2019
41b9636
mario doesn't fall out the window
olehsamoilenko Oct 10, 2019
cb5b957
Merge pull request #1 from lyshuga/olezha
olehsamoilenko Oct 10, 2019
9b48041
mario is black now, no sprites for him :black_circle:
olehsamoilenko Oct 14, 2019
56b6767
goomba is now red square :sos:
olehsamoilenko Oct 14, 2019
5cd05d6
obstacles & land are white
olehsamoilenko Oct 14, 2019
1c517b5
die when push enemy from the side
olehsamoilenko Oct 14, 2019
c36037f
collectible coin added, supercoin is orange
olehsamoilenko Oct 14, 2019
35ffba6
killing lava is added
olehsamoilenko Oct 14, 2019
e50afdd
mario doesn't fall out the window
olehsamoilenko Oct 10, 2019
397c200
mario is black now, no sprites for him :black_circle:
olehsamoilenko Oct 14, 2019
9a28e9d
goomba is now red square :sos:
olehsamoilenko Oct 14, 2019
51e4601
obstacles & land are white
olehsamoilenko Oct 14, 2019
01c67c7
die when push enemy from the side
olehsamoilenko Oct 14, 2019
96dea43
collectible coin added, supercoin is orange
olehsamoilenko Oct 14, 2019
f915a3a
killing lava is added
olehsamoilenko Oct 14, 2019
b726152
Merge pull request #2 from lyshuga/olezha
lyshuga Oct 14, 2019
06d55c0
Merge branch 'master' of https://github.com/lyshuga/OpenMario into ol…
olehsamoilenko Oct 14, 2019
e64fa28
Mario does not go throught the wall:
lyshuga Oct 14, 2019
7089953
Add friciton with ground (so less odd movements) and no FPS+keys are …
lyshuga Oct 14, 2019
dfe2fb8
Coin on top of the QuestionBox is added
lyshuga Oct 14, 2019
f51913a
Merge branch 'master' of https://github.com/lyshuga/OpenMario into ol…
olehsamoilenko Oct 14, 2019
138138b
Added width and height for StaticPipe
lyshuga Oct 26, 2019
f8997dc
falling lava added
olehsamoilenko Oct 26, 2019
d4d4477
add new level
Oct 26, 2019
ba5be84
fix adding coin above pushed box
Oct 26, 2019
7991fbf
Merge pull request #3 from lyshuga/olezha
olehsamoilenko Oct 26, 2019
f266580
#fixmerge
Oct 30, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ obj/
_ReSharper*/
[Tt]est[Rr]esult*
packages*/
/.vs/OpenMario/v15/Server/sqlite3
136 changes: 73 additions & 63 deletions OpenMario.Core/Actors/Concrete/Cloud.cs
Original file line number Diff line number Diff line change
@@ -1,63 +1,73 @@
//-----------------------------------------------------------------------
// <copyright file="Cloud.cs" company="brpeanut">
// Copyright (c), brpeanut. All rights reserved.
// </copyright>
// <summary> Code for the cloud actor. Inherits from the StaticTransparentBox class. </summary>
// <author> brpeanut/OpenMario - https://github.com/brpeanut/OpenMario </author>
//-----------------------------------------------------------------------

namespace OpenMario.Core.Actors.Concrete
{
using System.Diagnostics.CodeAnalysis;
using System.Drawing;

/// <summary>
/// Code for the Actor 'Cloud.'
/// </summary>
public class Cloud : StaticTransparentBox
{
/// <summary>
/// Initializes the drawable variable to the System.Drawing.Bitmap allowing us to draw on it later in the class.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
private Bitmap drawable;

/// <summary>
/// Initializes a new instance of the <see cref="Cloud"/> class.
/// </summary>
public Cloud()
{
this.Position = new VectorClass.Vector2D_Dbl(0, 0);
}

/// <summary>
/// Loads the cloud into the environment and defines the size and image for the actor.
/// </summary>
/// <param name="env">Base Environment <see cref="Environment"/></param>
public override void Load(Environment.Environment env)
{
this.Width = env.Width;
this.Height = env.Height;
this.Environment = env;
this.drawable = (Bitmap)Image.FromFile(@"Assets\cloudbg.jpg");
this.drawable = new Bitmap(this.drawable, new Size(500, 280));
}

/// <summary>
/// Draws the cloud into the environment based on the relative position.
/// </summary>
/// <param name="g">System Graphics <see cref="Graphics"/></param>
public override void Draw(Graphics g)
{
var pos = Environment.CalculateRelativePosition(this);

for (var curw = pos.X; curw < this.Width; curw += this.drawable.Width)
{
for (var curh = pos.Y; curh < this.Height; curh += this.drawable.Height)
{
g.DrawImage(this.drawable, (int)curw, (int)curh);
}
}
}
}
}
//-----------------------------------------------------------------------
// <copyright file="Cloud.cs" company="brpeanut">
// Copyright (c), brpeanut. All rights reserved.
// </copyright>
// <summary> Code for the cloud actor. Inherits from the StaticTransparentBox class. </summary>
// <author> brpeanut/OpenMario - https://github.com/brpeanut/OpenMario </author>
//-----------------------------------------------------------------------

namespace OpenMario.Core.Actors.Concrete
{
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;

/// <summary>
/// Code for the Actor 'Cloud.'
/// </summary>
public class Cloud : StaticTransparentBox
{
/// <summary>
/// Initializes the drawable variable to the System.Drawing.Bitmap allowing us to draw on it later in the class.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
private Bitmap drawable;

/// <summary>
/// Initializes a new instance of the <see cref="Cloud"/> class.
/// </summary>
public Cloud()
{
this.Position = new VectorClass.Vector2D_Dbl(0, 0);
}

/// <summary>
/// Loads the cloud into the environment and defines the size and image for the actor.
/// </summary>
/// <param name="env">Base Environment <see cref="Environment"/></param>
public override void Load(Environment.Environment env)
{
this.Width = env.Width;
this.Height = env.Height;
this.Environment = env;
var row = 500;
var columns = 280;
Bitmap B = new Bitmap(row, columns);
for (int i = 0; i < row; i++)
for (int j = 0; j < columns; j++)
B.SetPixel(i, j, Color.CornflowerBlue);
this.drawable = B;
//Bitmap B = new Bitmap(row, columns);
//Graphics G = Graphics.FromImage(B);
//G.FillRectangle(Brushes.Blue, 0, 0, row, columns);
//this.drawable = new Bitmap(row, columns, G);
}

/// <summary>
/// Draws the cloud into the environment based on the relative position.
/// </summary>
/// <param name="g">System Graphics <see cref="Graphics"/></param>
public override void Draw(Graphics g)
{
var pos = Environment.CalculateRelativePosition(this);

for (var curw = pos.X; curw < this.Width; curw += this.drawable.Width)
{
for (var curh = pos.Y; curh < this.Height; curh += this.drawable.Height)
{
g.DrawImage(this.drawable, (int)curw, (int)curh);
}
}
}
}
}
61 changes: 61 additions & 0 deletions OpenMario.Core/Actors/Concrete/Coin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
namespace OpenMario.Core.Actors.Concrete
{
using System.Collections.Generic;
using System.Drawing;

/// <summary>
/// The coin.
/// </summary>
public class Coin : StaticBox
{
private Bitmap drawable;

/// <summary>
/// Initializes a new instance of the <see cref="Coin"/> class.
/// </summary>
public Coin()
{
this.Width = 30;
this.Height = 30;
}

/// <summary>
/// The Load method for <see cref="Coin"/>
/// </summary>
/// <param name="env">The env.</param>
public override void Load(Environment.Environment env)
{
this.Environment = env;

Bitmap B = new Bitmap(this.Width, this.Height);
for (int i = B.Height / 3; i < 2 * B.Height / 3; i++)
for (int j = B.Width / 3; j < 2* B.Width / 3; j++)
B.SetPixel(j, i, Color.Yellow);
this.drawable = B;

this.CollisionAction = CollisionType.NoAction;
}

/// <summary>
/// The drawing method for the <see cref="Coin"/> actor.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> for the <see cref="Coin"/> actor</param>
public override void Draw(Graphics g)
{
var pos = Environment.CalculateRelativePosition(this);
g.DrawImage(this.drawable, (int)pos.X, (int)pos.Y);
}

public override void Update(List<BaseActor> loadedactors)
{
/* collision options */
foreach (BaseActor actor in loadedactors)
{
if (actor is Mario && Physics.Physics.GetCollisionType(actor, this) != Physics.Physics.CollisionType.None)
{
Environment.ActorsToRemove.Add(this);
}
}
}
}
}
60 changes: 60 additions & 0 deletions OpenMario.Core/Actors/Concrete/FallingLava.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace OpenMario.Core.Actors.Concrete
{
using System.Collections.Generic;
using System.Drawing;

/// <summary>
/// The FallingLava.
/// </summary>
public class FallingLava : GravityActor
{
private Bitmap drawable;

/// <summary>
/// The Load method for <see cref="FallingLava"/>
/// </summary>
/// <param name="env">The env.</param>
public override void Load(Environment.Environment env)
{
this.Environment = env;

Bitmap B = new Bitmap(this.Width, this.Height);
for (int i = 0; i < B.Height; i++)
for (int j = 0; j < B.Width; j++)
B.SetPixel(j, i, Color.DarkRed);
this.drawable = B;
}

/// <summary>
/// The drawing method for the <see cref="FallingLava"/> actor.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> for the <see cref="FallingLava"/> actor</param>
public override void Draw(Graphics g)
{
var pos = Environment.CalculateRelativePosition(this);
g.DrawImage(this.drawable, (int)pos.X, (int)pos.Y);
}

public override void Update(List<BaseActor> loadedactors)
{
/* collision options */
foreach (BaseActor actor in loadedactors)
{
if (Physics.Physics.GetCollisionType(actor, this) != Physics.Physics.CollisionType.None)
{
if (actor is Mario)
{
Environment.ActorsToRemove.Add(actor);
}
else if (actor is OrangeLand)
{
Environment.ActorsToRemove.Add(this);
}

}
}
this.Move();
Physics.Physics.BlockAllCollisions(this, loadedactors);
}
}
}
51 changes: 25 additions & 26 deletions OpenMario.Core/Actors/Concrete/Goomba.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ namespace OpenMario.Core.Actors.Concrete
/// </summary>
public class Goomba : GravityActor
{
/// <summary>
/// Initializes the _drawable variable to the System.Drawing.Bitmap allowing us to draw on it later in the class.
/// This instance is to draw the Goomba moving left.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
private Bitmap drawableLeft;

/// <summary>
/// Initializes the _drawable variable to the System.Drawing.Bitmap allowing us to draw on it later in the class.
/// Bitmap for drawing the Goomba moving right.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")]
private Bitmap drawableRight;

/// <summary>
/// /// Initializes the _drawable variable to the System.Drawing.Bitmap allowing us to draw on it later in the class.
/// Bitmap for drawing the current movement of the Goomba.
Expand Down Expand Up @@ -78,11 +64,13 @@ public override void Draw(Graphics g)
public override void Load(Environment.Environment env)
{
this.Environment = env;
this.drawableRight = (Bitmap)Image.FromFile(@"Assets\goombar.png");
this.drawableRight = new Bitmap(this.drawableRight, new Size(Width, Height));
this.drawableLeft = (Bitmap)Image.FromFile(@"Assets\goombal.png");
this.drawableLeft = new Bitmap(this.drawableLeft, new Size(Width, Height));
this.drawableCurrent = this.drawableRight;

Bitmap B = new Bitmap(this.Width, this.Height);
for (int i = 0; i < B.Height; i++)
for (int j = 0; j < B.Width; j++)
B.SetPixel(j, i, Color.Red);
this.drawableCurrent = B;

this.timer = new Stopwatch();
this.timer.Start();
}
Expand All @@ -101,9 +89,6 @@ public override void Update(List<BaseActor> loadedactors)
// Drawable
if (this.timer.ElapsedMilliseconds > 500)
{
// Swap drawables.
this.drawableCurrent = this.drawableCurrent == this.drawableLeft ? this.drawableRight : this.drawableLeft;

this.timer.Reset();
this.timer.Start();
}
Expand All @@ -119,11 +104,25 @@ public override void Update(List<BaseActor> loadedactors)
this.WalkingVelocity = new VectorClass.Vector2D_Dbl(this.WalkingVelocity.X * -1, this.WalkingVelocity.Y);
}

// If we got stomped on, we'll need to die.
if (Physics.Physics.IsActorPushingAnotherFromBottom(this, loadedactors))
/* collision options */
foreach (BaseActor actor in loadedactors)
{
// Queue the removal.
Environment.ActorsToRemove.Add(this);
if (actor is Mario)
{
if (Physics.Physics.IsActorStandingOnAnother(actor, this))
{
/* bounce over goomba */
actor.Velocity = new VectorClass.Vector2D_Dbl(actor.Velocity.X, (-2) * actor.Velocity.Y);
/* kill goomba */
Environment.ActorsToRemove.Add(this);
}
else if (Physics.Physics.IsActorPushingAnotherFromLeft(actor, this) ||
Physics.Physics.IsActorPushingAnotherFromRight(actor, this))
{
/* die */
Environment.ActorsToRemove.Add(actor);
}
}
}

// Normalize Velocities to only allow maximum speeds.
Expand Down
31 changes: 18 additions & 13 deletions OpenMario.Core/Actors/Concrete/GreenStaticPipe.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
//-----------------------------------------------------------------------
// <copyright file="GreenStaticPipe.cs" company="brpeanut">
// Copyright (c), brpeanut. All rights reserved.
// </copyright>
// <summary> Contains all of the logic for drawing and interacting with the Green Pipe. </summary>
// <author> brpeanut/OpenMario - https://github.com/brpeanut/OpenMario </author>
//-----------------------------------------------------------------------


namespace OpenMario.Core.Actors.Concrete
{
using System.Drawing;
Expand All @@ -23,10 +16,10 @@ public class GreenStaticPipe : StaticBox
/// <summary>
/// Initializes a new instance of the <see cref="GreenStaticPipe"/> class.
/// </summary>
public GreenStaticPipe()
public GreenStaticPipe(int Width = 40, int Height = 60)
{
this.Width = 40;
this.Height = 60;
this.Width = Width;
this.Height = Height;
}

/// <summary>
Expand All @@ -45,8 +38,20 @@ public override void Draw(Graphics g)
public override void Load(Environment.Environment env)
{
this.Environment = env;
this.drawable = (Bitmap)Image.FromFile(@"Assets\pipe.png");
this.drawable = new Bitmap(this.drawable, new Size(Width, Height));

Bitmap B = new Bitmap(this.Width, this.Height);
for (int i = 0; i < B.Height; i++)
for (int j = 0; j < B.Width; j++)
B.SetPixel(j, i, Color.White);

for (int i = 10; i < 20; i++)
{
for (int y = 20; y < 40; y++)
{
B.SetPixel(y, i, Color.Violet);
}
}
this.drawable = B;
}
}
}
Loading