MonoGame | One framework for creating powerful cross-platform games | Game Engine library
kandi X-RAY | MonoGame Summary
kandi X-RAY | MonoGame Summary
One framework for creating powerful cross-platform games. The spiritual successor to XNA with thousands of titles shipped across desktop, mobile, and console platforms. MonoGame is a fully managed .NET open source game framework without any black boxes. Create, develop and distribute your games your way.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of MonoGame
MonoGame Key Features
MonoGame Examples and Code Snippets
Community Discussions
Trending Discussions on MonoGame
QUESTION
I'm trying to create a PC version of a cord-driven turn-based boardgame. I went for the Monogame framework in c#. I'm still learning C# and Monogame and I'm reading all about how it is important to "split" the code in the data/game engine part and the graphics/GUI part. So trying to pursue this, I have the following in mind.
Graphics/GUI
Here I define all the classes relative to the screens (game - menus), GUI components like labels and buttons and possibly even mouse and keyboard inputs (the logic being the user has to click on something in the gui in order to perform an action).
Data or Game logic/Engine
Still not even sure on how I should call this part of the project, here I would put all the logic of the game. The classes of player, cards, "IA", rules etc... would be defined here.
My difficulty is now to understand how to connect this two parts but still maintain the "loosely coupled" approach. I was thinking that maybe the objects or better the instances of the game logic part would have to subscribe to events (such as button_click) defined in the GUI part...but can I even subscribe to events of another class? Is this the correct way?
I admit I'm still trying to fully understand the event driven concept, but is this the right way of doing stuff in c# and Monogame? I apologize for the vague topic/question but thanks in advance.
...ANSWER
Answered 2022-Mar-14 at 17:18I don't know anything about Monogame, but generally it's a good idea to organise any kind of application into layers like this, as long as you don't make the code overly complicated by doing so. Your idea to separate the UI code from the game logic sounds like a good start.
First, think of your application as an onion, with a series of concentric layers. Your proposed structure has only two layers, but that's OK. A larger application may benefit from more layers, e.g. a data access layer if you were to store the state of the game in a database, but there's no need to add extra layers just for the sake of having more layers.
Your outermost layer would contain the UI code, typically this is known as the presentation layer.
Your innermost layer would contain the game logic, typically this is known as the domain layer. A good rule of thumb for whether something belongs in the domain layer is to ask, does this represent something that a user of your application (or a player of your game) who's not a developer would recognise?
Second, remember that each layer can make calls to code in the same layer, or to code in in other layers inside it, but not to code in layers outside it. So projects in the presentation layer can have references to projects in the domain layer, but projects in the domain layer can't have references to projects in the presentation layer. If you've got circular references between the two layers then it's a sign that something in one of the layers actually belongs in the other layer.
Here's another answer to a similar question about layering an application, albeit not in the context of a game: https://stackoverflow.com/a/70315655/16563198
On the second part of the question, if you want to use events then it's probably best to handle any events in the presentation layer and have the event handlers make calls into the domain layer (but disclaimer, I don't know Monogame).
QUESTION
I was working on a game on my laptop which I now copied to my desktop (on which I installed Monogame 3.7.1). I can run the build from my laptop on my desktop, but when building it on my desktop (from Visual Studio 2019) it gives the error underneath.
I tried:
When I double click the Content file it opens up the MGCB tool and I can see the content tree fine and modify it. When I click Build it simply does absolutely nothing (output windows stays blank, like I didn't click, same for clean).
When I open the MGCB application and then open the Content file from within the application I can build it just fine (all successful, also when cleaning and rebuilding, everything works fine it seems).
When copied the command from the Visual Studio error in CMD I got a message that FreeType6.dll couldn't be loaded (a lot of people got this error). The DLL is in the same folder as MGCB (so it's there). I installed VC++ redis 2012, 2013 and 2015 (as people suggested and which worked sometimes), but that didn't help (I rebooted every time).
I installed all fonts I used for both the current (only) user on that pc and for all users, but that didn't help.
A lot of people seem to get stuck with the content build. I don't know where to look anymore. Does anyone have an idea on how to (try to) fix this in a systematical way? It's annoying this error keeps popping up stalling projects.
Thanks for borrowing you brain!
...ANSWER
Answered 2022-Jan-29 at 09:34It's working! :)
I followed the migration guide for MonoGame 3.7.1 to 3.8 and now it works again :). https://docs.monogame.net/articles/migrate_37.html
QUESTION
I´m trying to publish a package (which is build with the normal uwp-template from monogame) to the Windows Store and it shows the following message:
...ANSWER
Answered 2021-Dec-28 at 01:08Please change the minversion in the project file to the version the error message mentioned.
Like this:
QUESTION
I was wondering how to draw on the fly pixel by pixel in XNA/MonoGame and could only find this. Problem is, the question wasn't centered about how to actually draw pixel by pixel but rather manage resources and updating stuff.
Because I couldn't find any simple and short answer and was wondering how to do for some time now, I'll share a snippet I stumbled upon (see answer).
NB: If anyone having a better approach or an alternative method to do it, feel free to post or comment!
...ANSWER
Answered 2021-Nov-22 at 15:45You need to use the SetData()
method of a Texture2D
object you previously initialized with a 1 by 1 size.
Here's the code:
QUESTION
Even when I use GraphicsDevice.ToggleFullScreen() or GraphicsDevice.IsFullScreen = true; followed by GraphicsDevice.ApplyChanges() as described in this post, I still seem to have this border on both edges of the screen, shown in classic CornflowerBlue for contrast in this screenshot. The background image is anchored at 0,0 with width and height set to the dimensions of the screen. The "borders" seem to be about 10 or 20px from what I can guess, and not at the top or bottom, only at the left and right edges. I can't understand where this is coming from.
...ANSWER
Answered 2021-Nov-22 at 03:09If you want your game to be at full screen of every device:
QUESTION
I'm Trying to make a rougelike in C# using Monogame and RogueSharp.
here is some of the code I have in Draw()
...ANSWER
Answered 2021-Nov-18 at 07:14The Rectangle
constructor either takes (Point location, Point size)
or (Int32 x, Int32 y, Int32 width, Int32 height)
but not (Float, Float)
(what would that even mean?) - See docs.
So, two issues here:
- You need four values to uniquely specify a rectangle in 2D space, not two.
Rectangle
does that using X and Y of the top-left corner as well as width and height. - The
Rectangle
constructor expects those values as integers and not floats.
Looking at your code, I'm guessing that you want to create a rectangle that has sizeOfSprites * scale
as length of both sides, in which case you'd need to specify the size as follows:
QUESTION
I am currently coding an arkanoid type game for my school project and just started out on monogame. I encountered a collision problem on the big red rectangle and the ball. I just cant figure out what is wrong with my code I appreciate all of your help in advance.
Collision Video: https://youtu.be/HOuUS8bUKn4
Game1.cs
...ANSWER
Answered 2021-Nov-12 at 07:37This method is missing the necessary code to function properly to approach the block from any side:
QUESTION
I'm trying to draw a sprite to the screen in monogame but does not work. Does not give any errors. I've tried other images and it works with them. Maybe it has something to do with the image being .png? Please help me I can't figure this out
Code:
...ANSWER
Answered 2021-Oct-20 at 23:24It is easier to use the Monogame Pipline tool to process the PNG file into an XNB file first. Best cross-platform solution.
There may be times you need to load a PNG directly.
Add an existing file to the project in Visual Studio. Select the PNG file. Copy it.
Under properties in Visual Studio, set "Build type to none" and "Copy to output if newer".
Note this only works on Desktop platforms.
QUESTION
I have been trying to make a clicker game in monogame, But I can't figure out how to make a button. I've tried countless tutorials and none of them seem to work. What is the simplest way to make a button in monogame?
...ANSWER
Answered 2021-Oct-11 at 19:09Drawing is usually done with a single function call assuming you want to simply draw a image into the screen without any shader(s) or magic stuff:
QUESTION
Hello i'm developing a game in c# monogame and having issues with resetting the camera back to behind the player.
When the player holds left click he's able to orbit the camera around his character. When he moves forward the camera resets back behind him slowly. The rotation should decide whether it should rotate left or right around the player to behind the player (the shortest path). At the moment it sometimes orbits the long way around the player and worst of all the currentY will be stuck in-between 1 and -1 and keep moving back and forth really quick like its stuck.
...ANSWER
Answered 2021-Sep-17 at 13:57I solved the problem the code below will rotate between 360 degrees and 0 degrees, it also rotates between 170 degrees to 160 degrees, only posting incase it helps someone else.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install MonoGame
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page