/ User class & + Ball base class

This commit is contained in:
2022-10-17 23:09:06 +02:00
parent f8c64522b9
commit 55b74246e9
13 changed files with 692 additions and 7 deletions
+36
View File
@@ -0,0 +1,36 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-mac"
]
}
}
}
View File
+64
View File
@@ -0,0 +1,64 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace client
{
internal class Ball
{
private Vector2 Position { get; set; }
private int Radius { get; set; }
private float InitialSpeed { get; set; }
private float Acceleration { get; set; }
private int Delta { get; set; } // Delta time = milliseconds
// Constructors
public Ball(GraphicsDevice graphicsDevice)
{
this.Position = new Vector2(0,0);
this.Radius = 5;
this.InitialSpeed = 0.5f;
this.Acceleration = 0.1f;
this.Delta = 100;
}
public Ball(Vector2 position, int radius, float initialSpeed, float acceleration, int delta)
{
this.Position = position;
this.Radius = radius;
this.InitialSpeed = initialSpeed;
this.Acceleration = acceleration;
this.Delta = delta;
}
// Draw ball
public Ball Draw(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
{
spriteBatch.DrawCircle(
this.Position,
this.Radius,
360,
Color.White,
this.Radius
) ;
return this;
}
// Start | Stop ball moving
public Ball StartMoving()
{
return this;
}
public Ball StopMoving()
{
return this;
}
}
}
+27
View File
@@ -0,0 +1,27 @@
#----------------------------- Global Properties ----------------------------#
/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:DesktopGL
/config:
/profile:Reach
/compress:False
#-------------------------------- References --------------------------------#
#---------------------------------- Content ---------------------------------#
#begin ball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:ball.png
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

+13 -1
View File
@@ -5,8 +5,10 @@ namespace client
{
public class Game1 : Game
{
// Game instances
private Player pl1;
private Player pl2;
private Ball ball;
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
@@ -20,7 +22,6 @@ namespace client
protected override void Initialize()
{
// PLAYERS
pl1 = new Player(
new Vector2(15, _graphics.PreferredBackBufferHeight / 2 - 50),
@@ -36,6 +37,15 @@ namespace client
100f
);
// BALL
ball = new Ball(
new Vector2(_graphics.PreferredBackBufferWidth / 2 - 5, _graphics.PreferredBackBufferHeight / 2 - 5),
10,
0.5f,
0.1f,
100
);
base.Initialize();
}
@@ -60,6 +70,8 @@ namespace client
pl1.DrawPlayer(_spriteBatch, GraphicsDevice);
pl2.DrawPlayer(_spriteBatch, GraphicsDevice);
ball.Draw(_spriteBatch, GraphicsDevice);
_spriteBatch.End();
base.Draw(gameTime);
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

+3
View File
@@ -0,0 +1,3 @@
using var game = new client.Game1();
game.Run();
+43
View File
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="client"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>
+30
View File
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RollForward>Major</RollForward>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>
</Project>
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client.csproj", "{5AE7A447-37B1-45D1-91D3-664049C1645F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AE7A447-37B1-45D1-91D3-664049C1645F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AE7A447-37B1-45D1-91D3-664049C1645F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AE7A447-37B1-45D1-91D3-664049C1645F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AE7A447-37B1-45D1-91D3-664049C1645F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6144DBBE-D113-4BE0-A42C-4EFD38B1C0CC}
EndGlobalSection
EndGlobal