#monogame-and-libgdx-dev
3045 messages · Page 2 of 4
@compact willow iam making a timer class and i want to do
if (this.time <= 0){
this.function();
}
and i want this.function to be set by a paremeter when new object created (sorry for english)
so the function will have a void return type and no arguments?
it may have a arguments but i set them when creating the new object
the function's footprint needs to be absolute to pass it as an argument
ok i have to go to study now will try again when i comeback
you can use any delegate
Action<T> and Func<T> are just convenient generic options
@vale dew you have to remember that the method you're passing the delegate to has to be able to invoke it
Func<> and Action<> covers all the method signatures that you should ever need
if you know some arguments ahead of time, you could make an invoker object that holds both the arguments and the delegate and invoke that
theres also standard EventArgs<T> if you are doing events
you end up passing junk through them though, so unless you have a really good reason to pass a mostly useless object around, avoid them
i wrote my own event handlers for my UI code
event system*
explicit delegates are nice but not necessary
Hello there,
Got a small problem with my current Monogame project. I did rewrite an old game I did write back in 2015 with a friend of mine.
For the core system I did write a ECS system which consists of the following interfaces
IGameEngine
IEntityManager
IEventManager
The game manager holds a instance if an implementation of the entity- and eventManager interfaces.
Know I was thinking about adding some kind of screen mechanic so that I can create a instance for example the main-, setting menu or the game itself. Each screen is part of a manager class which is a finite state machine. Only one screen could be active at once and each screen can create a transition to another screen by either creating a instance and push it to the FSM or by pop itself so the last screen is reactivated.
Now I was thinking what to do with the "game engine" instance holding the components, entitles and systems there a two possible scenarios in my head but both just doesn't sound right.
Passing the "ECS" container around between the screens clearing the content between the screens
- This would get me into trouble restoring an old state from a previous screen because I did clear the entites. caching the entites, components and systems in the screen and freeze them to add them later on seems fishy
Create a new "ECS" instance for each screen. Because only one screen is active at the time only one ECS would be updated and drawn but somehow my mind thinks this idea is not right as well
Is there something I do miss or is my mind just playing tricks to me and one of the solutions is totally fine?
what are these 'screens'
shouldnt only one need an ECS? (also id separate the ECS from the screens, maybe put it into a game container you can pass around if necessary)
(your game engine is the ECS)
also i dont think you need it to be an interface, presumably theres only one version of it
A screen is some class implementing a interface
This "screen" should represent a state of the game such as a game menu
I think in unity this is called "scene"
The ECS itself is a "GameEngine" instance which holds a "EntityManager" and a "EventManager"
yeah, still seems like a spearate concept from your ECS
in my game, there is the UI code, which is any UI
the game and editor containers are both UI
the game and editor just have a reference to the current map/game instance
they're responsible for scheduling updating/drawing/etc the game, but the game itself handles everything game related
So let's think about the following situation
I do start the game the ECS is filled with an entity per UI element with the components and systems needed to get everything into a working state
Now I click on the start game button
If I clear the entities in the manager everything is gone, which is okay in this situation
If I stick to this solution if I want to implement a pause menu in the game I need to delete all entities which will prevent me from restoring the old game state
I can't get my head around this problem 😦
why is your game code coupled to the UI like that?
why do you need to delete entities to display a pause menu?
I could add a "disabled component" to them to tag them as inactive
Which could be implemented into the systems to stop watching all entitles which are tagged as disabled
still dont know why these two things are coupled like this
Do you know the Entity Component System?
Maybe I did implement something wrong
yes
ECS is not a catch-all solution
i still dont understand the relationship between your game entities and your UI code
ECS is not a catch-all solution
@compact willow I know that it's just another way to represent your game entites
And the system is not the solution for every problem for the game structure
right and the architecture need not be ubiquitous
right and the architecture need not be ubiquitous
@compact willow So it is totally valid to use the ECS only in the game itself
For other screens like the menu something simpler could be used?
Right. Only use ECS where ECS is warranted.
And always make sure that your UI logic is completely decoupled from your game logic
you can also have an ECS for your UI and an ECS for your entities
or even if you combine them, the UI can be loosely coupled to your game entities
that too
I've been told that ECS is deceptively good for UI work
i still dont understand the relationship between your game entities and your UI code
@hot hazel At the moment In my thinking an UI element is a entity with components representing the element
As example an visibleComponen
An PositionComponen
And clickableComponent
Some system is doing the logic
That's why in my head the things are so tightly coupled
well if you want, you could have an EntityHUD system or something?
theres several ways you could handle this
but you are going to likely want a UI hierarchy/tree
and all entity UIs go into one node
your pause menu/game code could disable the entity UI while the pause menu is active
So to rethink the whole problem:
There are screen/scenes which can use different systems
As example the game screen could use the ecs while a "menu screen" is using a Object-Oriented data structure to represent a UI
Each screen is a own set of logic and data?
So using a different system per screen is totally normal
Because my next "problem" was how to create a text box with ECS where I need a system keeping track of the buttons firing events like crazy 😄
Is this correct?
i would decouple the UI from the ecs
if you want your entities to have UIs make a system/component that interfaces with your UI system
Hmm there is no real UI in the game
The game is some kind of cannon hill clone
So there could be some health bars
A gui showing the direction and force of the canon
Any some kind of box where you can see which projectile you did select and how many are left
So I think I will use the old approach before creating the ECS
I will create a new UI system which is working correctly :D
Use a screenmanager to get transitions and use the ECS only in the game itself 🙂
thanks @hot hazel
Xanatos gave karma to CobaltHex
thanks @compact willow
Xanatos gave karma to Kaho
How does monogame compare to libgdx? Is it better at cross compiling to targets?
@gray heron according to their website, libgdx supports building for Windows, Mac, Linux, Android, iOS, BlackBerry and HTML5.
MonoGame supports building for Windows, Mac, Linux, iOS, Android, tvOS, PlayStation 4, PlayStation Vita, Xbox One and Nintendo Switch
So monogame has better (ie: has) smarttv and console support, but libgdx has slightly better mobile support, and web support
Yea they claim that but I'm just wondering if someone actually has experience with the two
and blackberry doesn't count lol
its really just ios + android, I need top notch support for them two
(MonoGame also supports windows phone but.. y'know)
ok i have a problem and i dont know why it happens
iam making a clicker game and this happen when i try to handle clicking with event handler
public EventHandler click;
public void update(gameTime dt){
if type == "first" {
this.score_increasment = 1;
this.click += new EventHandler(delegate (Object sender,EventArgs e)
{
Game1.score += this.score;
});
}
if (this.mstaten.LeftButton == ButtonState.Pressed && mstateo.LeftButton == ButtonState.Released && this.rec.Contains(mousePosition))
{
click.Invoke(this,new EventArgs());
}
}
and when i run it it increase the score with random number instade of 1
ok nvm i fixid it
it works when i put it in the constructor instade of update
well yeah with that code you're adding the event listener on every update
Would creating an editor for my monogame engine(if you can call it that) be worthwhile?
If so, where would I even start? lol
depends on what you want
may make it easier
if thirdparty tools work why bother
my game has an editor built in so that in theory others could make content
(should anyone ever play my game 🙂 )
@hot hazel What did you use for your editor?
Just ingame gui?
i made everything
but yes its using my gui code
Ah gotcha
@proper stone first you need to figure out something that makes your editor special enough to be worth making. Since you're probably gonna spend somewhere between 80 and 800 hours making it
assuming its a relatively simple editor tailored specifically for the game your making
if you don't expect to save at least twice that by partially automating your tasks, then don't bother. Better off spending 8-40h writing pipeline extensions for editors that fit your need
fuck pipeline extensions
just write it into your game code
sure, as long as you only ship on one platform, don't care about the size of your game and never plan to ship asset updates
oh and dont care about load times
none of those things are restricted to a pre-compile content pipeline
also you dont have to use the monogame one
if you're making an AAA 3d game sure
@quiet ibex I just want to do it for fun
For the experience
Anyone here?
I am trying to make a rectangle that will cover the background
graphics.PreferredBackBufferWidth = 1200; // Game Width
graphics.PreferredBackBufferHeight = 700; // Game Height
graphics.ApplyChanges();
I created this but it doesnt seem to work
Rectangle Screen = new Rectangle(0, 0, 1200, 700);
doesnt the resolution start from 0, 0
how are you rendering it?
spritebatch?
@peak nacelle a Rectangle is just a struct that describes the position and dimensions of a rectangle, its not visible unless you draw something looking like it
Im not drawing it
I want it to use is for
.Interacts
So i dont need to
@peak nacelle the 0 position of the X and Y axis is not tied to the screen itself
you should set the X and Y to Game1.GraphicsDevice.Viewport.X and Game1.GraphicsDevice.Viewport.Y
X and Y in the way that you are using them are just world coordinates, when working with UI it is good to use screen coordinates
if you have a camera that moves around the world your X and Y positions will be left behind
also you said .Interacts I hope you didnt just type the method incorrectly in your code it should be .Intersects
Yeah thanks
Anyone think they can help me fix this? https://gyazo.com/b5e76b1df310471cba2d1b494876c511 I've never really used wpf/xaml before
Rectangle Screen = new Rectangle(0, 0, 1200, 700);
Rectangle Tank2Rectangle = new Rectangle((int)Tank1[0].Position.X - 68, (int)Tank1[0].Position.Y - 29, 98, 60);
Rectangle TankRectangle = new Rectangle((int)Tank[0].Position.X - 68, (int)Tank[0].Position.Y - 29, 98, 60);
bool inBound;
if (TankRectangle.Intersects(Screen) || Tank2Rectangle.Intersects(Screen))
{
inBound = true;
}
else
{
inBound = false;
}
if (inBound == false)
{
Tank1[0].Position += Tank1[0].Direction * -5f;
Tank[0].Position += Tank[0].Direction * -5f;
}
shoudnt these recrangles intersect?
idk why they dont
or at least if they do
my if statements dont work
If the screen rectangle is in the tankrectangle when the game loads
will this affect it?
does .intersect mean they first dont have to intersect
@peak nacelle use breakpoints and inspect your variables, the positions are probably not what you think they are
and you might as well do csharp if (!TankRectangle.Intersects(Screen) && !Tank2Rectangle.Intersects(Screen)) { Tank1[0].Position += Tank1[0].Direction * -5f; Tank[0].Position += Tank[0].Direction * -5f; }
yeah they are not what they are supposed to be
false instead of true
idk why
i drew the rectangles
and they are correct
they should intersect
I am not exactly sure if intersects works when on rectangle is completrly inside the other @peak nacelle
yeah i think so too
what else can i use tho?
I think you can impmement your own AABB
Or if u want rotatuins some OOBB would be good to go to
@peak nacelle the standard rectangle intersection works for all cases, have you inspected the values live, or just deduced what they should be by looking at the code?
i drew the rectangles
and i know for a fact
the tankrectangle
is inside the screen rectangle
when game loads
but the code says
its not
i @quiet ibex
@peak nacelle then you didn't check the actual values, you need to use the debugger
rectangles can intersect other rectangles that are 1pixel x 1pixel large, a full rectangle overlap will still count as an intersect
i have used a 1pixel rectangle at the point of my mouse cursor to show intersects with my mouse and other rectangles
@peak nacelle just start typing Console.Writeline(Tank2Rectangle) or Console.Writeline(inBound) in different parts of the code and watch for any relevant data on the console when you launch your program
we dont know what your Position value, and you offset the rectangle of your tank by 68 pixels to the left of your position, so maybe the tank is off screen by 68 pixels
you can also try building your screen rectangle to be half the size of your actual screen so you can see if anything is happening outside the Screen rectangle
also show us what your direction vector is looking at and explain why you are using negative velocity, you want the tanks to move away from the screen when they leave the boundary?
Its fine melt
i fixed it
using another method
idk why it didnt work
@frigid dagger
r u online?
How can i make an effect stop playing?
i used
if (Keyboard.GetState().IsKeyDown(Keys.W))
{
Position += Direction * LinearVelocity;
effect.Play();
}
but i cant find something that will stop it from playing
is that a sound effect?
if so, that returns a SoundEffectInstance that has Play/Stop/etc on it
Ok thanks
Hey all, Anyone about that uses monogame and willing to spare a min? 🙂
!dontask
@flat osprey ^
Ah cool, I managed to sort my previous problem but now I have a new one haha. Do you know how to resize a texture in monogame by any chance? 😄
Also.. I mean like how could you set a percentage for scale, Using rectangles atm to try and scale it
As we uses libgdx, feel free to ask anything about coding.
@wide lava #show-off-your-work
@hot hazel Ok. I delete that post. 👍
@flat osprey
if you are trying to scale individuals sprites you can draw them with method 5 of 7 in spriteBatch.Draw
spriteBatch.Draw(texture, rectangle, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 1f);
your first rectangle is the physical rectangle of your sprite, the sourceRectangle is used on your texture to find the coordinates and size of the sprite you are using
so if you upload an image that is 32*32 pixels in the top left corner of your sheet, you can identify the source as (0, 0, 32, 32)
now you can make your actual in game rectangle to be new Rectangle(positionX, positionY, 32 * 2, 32 * 2) this means you will represent the source image 2 * larger
if you want to use a percentage of scale you can make a quick conversion,
int percentageScale = 100;
float trueScale = percentageScale / 100;
and then use trueScale on your rectangles width and height fields, the width and height of a rectangle cant be represented by a float but you might have a 150% value in some cases so create the width and height of your rectangle separately then use it in the rectangle as an int.
Alternatively you can scale sprites using method 6 of 7 of draw. In this case there is a field that takes a float scale with 0f value being no scaling applied.
this method doesnt use rectangles for positioning, it applies the scaling onto whatever your source rectangle is, and positions the sprite at a vector2
the final method is applying a scale to your entire spriteBatch by use of a scale matrix
create a matrix somewhere that you will access it in your spriteBatch.Begin method
Matrix scale = Matrix.CreateScale(1f);
and use overload 5 of 5 in your spritebatch.begin
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, scale);
this is the most vanilla way to create a spritebatch with a scale added and not worrying about other fields.
the scale of a matrix should be 1f to show 100% of your sprites size, but just as earlier you can change the float to 1.5f etc. if you feed it an int of 150
i would advise not using the percentageScale, id also recommend using floats all around, you'll get a lot more precision
so i was looking for a timer and found System.Timer and its good but when i want to make like dealy betwen action and another and it make the code complecated and big so is there is any way i can do it ?
I'm not sure what you're trying to do exactly but you probably want the monogame timer over system.timer
i want to make it like after(x,somthing_to_do) or every(x,somthing_to_do) and like this
@vale dew here's the thing, its a lot more complicated than that. You have to remember that the simulation updated in increments, so you'll be timing your stuff to coincide with an update/draw and depending on what you're doing, you may need to compensate for the action happening late
so what you really need is a scheduler, so you can say "invoke this action in that timeslot"
this way you'll be able to schedule things and still maintain the execution order in each update/draw
if i want to use a 16x16 tileset for a top-down, but those tiles are too small on the screen (1920x1080) is the best way to increase the size to use scale 2.0 in Draw()?
It looks a little fuzzy when i do that
@tribal compass there are various ways of going about it, but the simplest one would be to switch sampler state to point sample
do you have a docs link? I'm not sure how to do that
its a parameter you pass to spritebatch.Begin()
ah
okay i'll try that, thanks
@vale dew heres an example of a timer using monogames gametime.
double timer;
inside your Update(gameTime)
{
timer += gameTime.ElapsedGameTime.TotalMilliseconds; //this returns the number of milliseconds passed since last update in a 60 frame game it is usually 16ms
if(timer >= 1000) //1000 is milliseconds - so 1 second
{
//perform action here
timer = 0; //set the timer back down to 0
}
}
you basically want to create a variable that counts up by 16 milliseconds every single game loop and when the milliseconds reach your desired number you perform your action and reset the timer to 0 so it can start counting again
Does anyone have a guide on programmatically determining tiles based on a grid in a top down game?
G G G G
G D D G
G G D G
G G G G
like what's the best practice for drawing the correct tiles in each position here, assuming G is grass, D is dirt, and the tileset has a tile for every corner
@tribal compass you'd want to read up on Wang Tiles, by storing your information slightly differently you can index the tiles directly using it
but for a corner, you'd do a walk around the tile, starting at the top and checking 3 tiles, if the second tile is empty and the other 2 are filled, then its a corner
you'd need to run that check 4 times for every tile, so you still want to bake the result
Tiled has proper support for all of this, so i'd recommend you switch map editors https://doc.mapeditor.org/en/stable/manual/using-wang-tiles/
I was able to get most of the way there last night by building an algorithm that does the walking and checking
Still some bugs to work out, but that seems like the only solution.
Every time a player changes the tile, the algorithm checks the neighbors of all affected tiles adjacent.
And updates the map appropriately
@tribal compass I did something like that. the issue comes from the amount of tile types you have. If you check the center tile + the surrounding you need to basically check the 3x3 grid. So you have 2^9=512 possible patterns. if you have 3 its 3^9=19683 possible patterns... depending on what you try to do, you run into a complexity issue.
@frigid dagger i do not recommend keeping time in a double like that
id do something morel ike ```TimeSpan lastUpdate;
void Update(GameTime gameTime) {
if (gameTime.TotalGameTime > lastUpdate + TimeSpan.FromSeconds(1)) {
...;
lastUpdate = gameTime.TotalGameTime;
}
}
@lament gyro There are a lot of possible patterns, but I only run the check on the affected tiles with every click, only when the tiles actually change. I then save the results to the map. It's complex, but it doesn't have an impact on performance that I've detected. Hopefully down the road when its time to do some refactoring I'll find ways to make improvements.
What I did, was creating a dictionary with the tile patterns as the key that returns the texture index as value.
yeah, that's the map
the player can change the map, so i need to have an algorithm pick t he right texture
to reference
have you programmed it by hand with if then elses or what was your approach?
i do all my programming with my hands
two for loops, i and j from -1 to 1 around the clicked square
that handles all the surrounding squares
each square i look at all of those surrounding squares
and i have a clunky set of boolean logic for each potential tile
in if-else
!IsDirt(Map[x - 1, y - 1]) && !IsDirt(Map[x, y - 1]) && !IsDirt(Map[x + 1, y - 1]) &&
!IsDirt(Map[x - 1, y]) && !IsDirt(Map[x + 1, y]) &&
!IsDirt(Map[x - 1, y + 1]) && !IsDirt(Map[x, y + 1]) && IsDirt(Map[x + 1, y + 1])
)
{
Map[x, y].Sprite = TileSprite.TopLeft;
}```
that is the exact thing I did at first too.
but I ran into issues with it when I wanted my map to be more komplex
like having gras, dirt, sand, mud, and so on tiles... maybe some water ontop of it
my design wouldn't allow for a tile to be more than one thing and it would not allow the player to modify a square in contact with 'blocked' tiles
so i think as long as my logic doesn't break it should be fine
then stick with it
but my tile system isn't going to be more than water, dirt, grass, or tree
at least in this part of the game where the player can modify the ground
I'm just asking, because I ran into a lot of problems when trying the same thing 2-3 months ago.
but I didn't want to enforce "map creation" rules, because my map is randomly generated... It was a lot more difficult then i thought at first
yeah that's why i'm not trying to do procedural/generated maps
its hard enough to get this part to work for now
but i imagine it comes down to careful, meticulous organization
because as far as i can tell there are no short cuts
If you want to see a great ingame map editor in action, you can take a look at rise to ruins. helped me a lot in understanding some approaches.
its not in scope for my current project, but i'll keep it in mind
the best i've seen so far is dwarf fortress
I just know the ascii one, never dug into it. :\
that's the one
you can add tilesets
there are plenty
its map generation is far more impressive than anything else i've seen
i just wish they could figure out some of the performance problems in the game
I'm totally confused right now :D
I did write a wrapper class for the keyboard class so I can use it with my dynamic controls system
class KeyboardWrapper
{
private KeyboardState previousKeyState;
private KeyboardState currentKeyState;
public void UpdateState()
{
Console.WriteLine("currentState: " + previousKeyState.IsKeyUp(Keys.Space));
Console.WriteLine("StateToSet: " + currentKeyState.IsKeyUp(Keys.Space));
previousKeyState = currentKeyState;
//Console.WriteLine("newState: " + previousKeyState.IsKeyUp(Keys.Space));
currentKeyState = Keyboard.GetState();
Console.WriteLine("RealState: " + currentKeyState.IsKeyUp(Keys.Space));
}
public KeyboardState GetState()
{
UpdateState();
return currentKeyState;
}
public KeyboardState GetPreviousState()
{
return previousKeyState;
}
public bool IsKeyDown(Keys key)
{
return GetState().IsKeyDown(key);
}
public bool IsKeyUp(Keys key)
{
return GetState().IsKeyUp(key);
}
public bool IsKeyPressed(Keys key)
{
//bool currentDown = currentKeyState.IsKeyDown(key);
//bool previousUp = previousKeyState.IsKeyUp(key);
//return currentDown && previousUp;
return false;
}
Now if I press the space key I check on the UpdateState the "currentKeyState" is always true. Anyone can spot my mistake?
currentState: True
StateToSet: True
RealState: False
class StaticKeyboardControls : IGameObjectController
{
private readonly KeyboardWrapper keyboardWrapper;
private Keys fire = Keys.Space;
public Keys Fire => fire;
private Keys strenghtUp = Keys.W;
public Keys StrenghtUp => strenghtUp;
private Keys strenghtDown = Keys.S;
public Keys StrenghtDown => strenghtDown;
private Keys rotationUp = Keys.A;
public Keys RotationUp => rotationUp;
private Keys rotationDown = Keys.D;
public Keys RotationDown => rotationDown;
public StaticKeyboardControls()
{
keyboardWrapper = new KeyboardWrapper();
}
public bool IsFirePressed()
{
keyboardWrapper.UpdateState();
return keyboardWrapper.IsKeyPressed(fire);
}
}
Thats the current implementation of the class using the wrapper, the idea is to provide a interface which can be a controller or a keyboard
The class is not done yet.
I do call it for testing purpose on the Update function
var test = new StaticKeyboardControls();
if (test.IsFirePressed())
{
//Console.WriteLine("Fire!");
}
AND I think I did spot my error just yet -.- creating a new instance in every update is not a good idea :D
Thank you for reading this 😄
Now it is working, stupid me 😄 -.-
@orchid frigate you want to make sure the update in th wrapper happens only once per frame
otherwise you'll miss presses and releases
Has anyone run into issues with using static classes to handle common functions used across the game?
performance-wise
I have an inventory interface and I don't want to avoid re-writing common actions like adding things to the inventory
@tribal compass a static method is the least costly method to invoke, although for the most part a member method has the same invocation cost
and if you're gonna make it static, you should consider making it an extension method, if one of the parameters are clearly the intended context
okay that's what i figured
i'm not a fan of extension methods, but that's just a personal thing
why not? makes your api far more discoverable
@tribal compass did you even read that article? he was arguing against turning instance methods into static methods, not against extension methods themselves
i understand
contains a lot of the points i don't like about extension methods
anyways, i'm trying to figure out how to do what i'm looking to do and I don't have the answer quite yet
don't really appreciate the accusation that i didn't read an article i used as justification, don't really understand why that was necessary
well you said you didn't like them and cited the article, presumably as the reason for why
correct
and it is still the reason why
i don't like statics in general so i'm looking for a better solution
well you gotta do inheritance-based oop then
hmmm
probably going to go with dependency injection that i followed at one of my previous jobs
why means you need to know which data you need up front, so you can slice it up into objects suitable for the problem at hand
dependency injection solves a completely different problem though
ok
since its all about the initialization andgetting the data to the right place
wont solve stuff like adding items to an inventory
I can use the constructor of the Inventory to have its own instance of InventoryManager
sure, but then you're using InventoryManager like a static class, ending up with the stuff you said you wanted to avoid
no, i'm good with it working that way
easy to mock for unit testing
avoids statics
doesn't hide implementation
can enforce things through the IInventory interface
normally you'd want to mock data, not functionality
If i need to unit test Inventory, and it has a property InventoryManager, I'll need to create a mock of Inventorymanager
Or else my unit test is also testing InventoryManager
and if you have static methods then you'd mock the inventory to test the methods
yes but then i'm using static methods
which i would liek to avoid
so i dont see how using the manager pattern would make things easier to mock here
i'm not saying use static methods, i'm just not seeing how they're bad for mocking
i didn't make any comment on whether or not static methods were easer/harder to mock
the pattern I'm currently sold on allows me to mock the properties in my classes
that's all
fair enough, didn't think you where running a monologue there
ok
Any engine programmers here?
!dontask
@raw warren everyone is making some sort of engine here
I'm looking for some help with my 2D voxel game engine's physics/collision. I've been working on this for a few weeks and I can't figure out what I'm doing wrong with my AABB collision detection - https://pastebin.com/pwAg6ena https://drive.google.com/file/d/1WSf2fJX8uwkPccFUhm6g2PjrzHR25sph/view?usp=sharing
I'm trying to achieve something similar to terraria or minecraft's collision system where you can fall down a 1x1 hole and not get stuck on the corners
got a video/gif?
also i recommend something like github
I made some changes to it so let me make a quick gif
(changes since the last gif I made, the code is current)
i would prefer not to read an entire project of code
hold on imgur is not letting me upload the gif
I'm going to make a webm instead
pretty much everything is in Actor.cs which is the pastebin link, but I included all of the relevant code in a zip on the google drive link just in case
first step would be to shrink the AABB
i recommend drawing it overtop the player as like a red rect or something
so you can see where its getting stuck
Good idea, I really should have just drawn some debugging stuff. Just added it and it looks like my AABB is actually working fairly close to how I want it to, but my player is not being updated properly
id draw an open rectangle above the player for better clarity
also maybe if you can highlight collisions
but it doesnt look like it perfectly matches the player
it looks like its clamped to the grid
I changed floor to round and it's a bit better, but completely stopped collisions, debugging now
@mighty dagger there's no reason your Actor class should own the AABB implementation. You could clean it up a lot by separating the intersection checks to a separate class
I've posted this in "shader-dev" but this channel seems to be also relevant.
I'm working on a cross-platform node-based material editor similar to my previous similar project (https://itch.io/queue/c/290843/urho3d-projects?game_id=273385 https://www.youtube.com/watch?v=DGMyL1ZK5WE ). The UrhoSharp engine seems to be dead so I'm working on generalization of the tech and making it configurable to various engine. I've already build the base of the new editor - a Spirv node-based shader viewer and about to start building the actual meat of the new one. The idea is to have a visual material and a tool to generate shaders for render passes for different platforms via spirv-cross, etc. Would you be interested in contributing to the project? Or, at least, do you see such project be useful to your project?
Please mention me in a reply so I can get notification.
please do not advertise in this channel
im sure someone will find it useful, though monogame nor (i assume) gdx support spirv
@earnest wigeon where's the monogame integration? and why are you linking to an itch.io page when you want contributors? should've linked to github instead
@hot hazel the editor suppose to generate spirv that could be translated into HLSL, GLSL, MSL, etc. Game engine doesn't need vulkan support to use it.
meh, a lot of work for likely wasted effort
monogame uses a custom cross platform HLSL compiler
@quiet ibex there is no game engine integration at the moment as it's not even close to completion 😦 Itch.io proves that it is doable as I already did it for a different engine (Urho3D).
CobaltHex, so you sure a visual shader editor won't be useful for monogame?
not saying it wont be
just having it output to spirv not likely
unless you want to write a compiler for fx/mgfx
spirv-cross suppose to take care of it
it can output hlsl and then one can compile it into fx, I guess
fx is a compiled hlsl shader, am I right?
no
fx is a legacy hlsl format
mgfx is the monogame-specific compiled version of that
I see
fx is the effects framework, which may also give you trouble, (though basically just need to bundle things into passes, all stages go into a single file, few other changes)
basically a dx9 relic
I kinda remember it from old times but I was using OpenGL back then so I'm not very familiar with it.
it'd need to be able to be limited to dx9 features on the output or its going to end up being unusable for monogame
is there a lowest shader model version to be supported?
dx9 is quite flexible on it
ragath i think monogame actually supports dx11
2.0 i think is the lowest i think gleb
i think you can compile 4.5 or 5.0 shaders too, but they may not work on ogl targets
the tech supports it, but not the effect class
you can write your shaders in sm 5.0, just not use things like structured buffers/etc
Hi! 🖐🎮
hi
Hi! I am doing my first steps with Monogame, I have followed the Getting started tutorial from the official website and it's working ok, but I have a question: the code to prevent the ball from getting out of the window is on the "Update" method, so it is calculated at every loop, even when it does not really change (or not often). But couldn't find a way to move it to the "Initialize" method since the texture width/height is used to get the limits, and the texture is not set until the "LoadContent" method. And putting it there seems a little out of context. Any idea? 🙃
put whatever check you want in the load content method
Initialize might come after load content im not sure, but it doesnt really matter imo
Initialize comes before LoadContent. But like Cobalt said, you can put the check in LoadContent. If you want it to make sense, just think of the method as "when the content is to be loaded". So: "when the content is to be loaded, load the texture, store it into a variable, and set the width/height limits based on the texture".
All right, thanks a lot!!!
just migrating back to monogame for a bit of fun but, it appears to hate VS 2017
there's new things called NuGet packages? they never had this when I programmed in monogame ages ago, this thing won't install now cause
really i was going to go back to vs 2013 at this rate cause this is really crap
there's so much junk with monogame now
like i don't even understand what is going on here, I never saw this crap when i was coding in VS years ago
NuGet packages allow you to import code
For example, I imported the AnimatedSprite class
Also, I’ve never once had that issue you pointed out in your last screenshot (I am also using VS 2017)
yeah this is a fresh monogame install too
i simply am too small brain to figure out what's going on

"using directive is unnecessary"
it's auto generated
why is this thing such dumb
i'm pretty sure all my public key tokens are messed up
why would that be when this is a fresh install?
no idea
well ok
now i'm getting some where
https://community.monogame.net/t/monogame-win-10-universal-template-fails-to-load-in-vs-2017/9228/5
Now I am here downloading a new windows SDK
Right after all that fixes I now have this
I was useing the "MonoGame Windows 10 Universal Project" now I'm using the "MonoGame Cross Platform Desktop Project" because of this error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'SharpDX, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'. The system cannot find the file specified.'
It all looks like it works to me so i don't care it's only to mess around in now
sadly monogame hasn't managed it's nuget dependencies well in the past, so might have to reference the correct sharpdx nugets manually
i recommend installing mongame on your machine
that will also give you the tools
true, but its still better to have nuget dependencies
Now that I'm thinking about it I think I've had that problem as well, having to add SharpDX to Nuget for the DirectX project to build
Somehow I managed to get everything in Nuget. Someone added the pipeline tool for Mac and Windows, so now you can clone my project, restore Nuget packages and you'll be all set. We had to do it that way cause my partner was working on his University's computers at the time and they don't have admin access to install MonoGame
now that they're adding support for .net core projects, it also opens up the possibility of creating a meta package that retroactively adds the nuget dependencies that monogame should've had in the first place
oh nice
cause that was a nightmare
Height based landscape maker
Exports to a 1024x1024 image, that will be used for height data, now, this will be able to generate land mass and have it kind of how dwarf fortress does it but I'm using this for a base landscape
I have to fix the performance issue with it which I have an idea for this
that is a painful blue
it's definitely very bright
ok ok why is it called visual studio 2019 when its updated in 2020 🤔 🤔
cuz they havent bothered to make a new proper release
if they plan to at all
they've released every 2-3 years since the dawn of time pretty much. doubt it'll change now
Anyone able to help me with implementing movement to my cars in MonoGame?
!dontask
Fair enough
Does anyone know a good solution for "reusing" the vertexbuffer of a SpritePatch?
What I wanna do, is let the SpriteBatch generate the vertex data for my tile map, so my cpu doesn't need calculate/upload it for every frame.
Probably just use an actual vertex buffer: http://rbwhitaker.wikidot.com/index-and-vertex-buffers
And then you can render it with BasicEffect. You'd need to set up a projection matrix, I usually just take the same one MonoGame's SpriteBatch class uses and then apply a transform matrix to it.
yea you want a vertex buffer optimized for static usage
but you need to consider the layout in the buffer, so you aren't pushing all the off-screen vertices through the gpu in vain
thx for your answers, I was afraid ther isn't an "easy" solution.
the offscreen verts aren't really an issue imho. the cpu time of creating the verts is much more precious.
@lament gyro its a big deal when your tilemaps get larger, here's an example implementation of it https://github.com/Ragath/TileRenderer
it basically sets up screen-sized rows of vertices going in a vertical zig-zag pattern across the screen. that way the gpu knows the position of the first and last visible vertex in the buffer
my map is chunked (32x32 tiles), so I can decide wich chunk to render. checking for each vert or tile if it is in visible, might be more costly than beneficial. But I'll think about it.
there's even faster ways of rendering huge tilemaps using a shader that samples 2 textures, but it runs into precision issues on some gpu's at certain mapsizes
the rendering takes so little time when using it, that you can see noticeable fps drops just by moving your mouse across the screen though
11k fps was the most i managed to crank out of it
11k is a litle more then I need. 😉
my issue is, that my map is pretty dynamic (chunks get load/generated, tiles are animated and can be changed), so I have to balance speed and flexibility.
but I defenetly never need to do it more then 30-60 times a second.
you want to avoid generating chunks during regular gameplay if you can help it. most procgen algorithms generate a fair bit of garbage
I have that part working, its on its own thread, so there are no bigger issue.
i was doing a 2d zelda style game with generated levels, but i hid the generation when transitioning between dungeons and the overworld
the gc stalls all threads, not just the one doing the work
I know, it's a bit of a pain, but exceptable for my game. I'll try to optimize that, if it becomes a real issue.
heres my impl of the tilemap shader https://bitbucket.org/cobalthex/dyingandmore/src/default/Media/Shaders/Tiles.fx
sorry, im not that used to reading shader code. Does this get a texture with colors that represents the the tiles and it basicaly creates them with the right texture?
so theres two textures
one is your tilemap texture
the other is your tile layout in the form of a texture (basically upload your tilemap array as a texture)
then the shader, when rendering the map divides the texel position into tilemap squares
finds the right tile to draw from the tile layout texture and draws the corresponding pixels from the tilemap texture
(some math there, not too complicated)
could be an interesting approach... thx
it is 100000% more efficient
is there any benchmarking you have done? how many tiles are doable?
the beauty of doing it in a shader
it will always take the same amount of time regardless of the size
only factor is size of viewport (number of pixels rendered)
theres probaply the max texture size limit too
modern GPUs no
(not practically at least)
dx9 era was 2048x2048
and if you need you can always chunk it, but i doubt your map will be larger than like 2^32
for now I think the "classic" approach is easier to implement, but doing it that way sounds realy interesting...
meh, i would say this method is worth figuring out
the "issue" is, that my map is composed of more than one layer. that makes it a litle more complicated
and im not 100% convinced that this is "that" much faster, then just rerendering the vertex buffer.
for now, being flexible is major point.
so if you had a vertex buffer
but Ill defenetly tinker around with it
you quads for every tile
vs one quad
if I get 100+ fps on low end PCs with both methods, why should I care about more complicated one?
it is much faster, the difference between rendering a vertex buffer and rendering a fullscreen dual-textured quad is huge
but there is a size limit you'll hit, not because of the size of the texture, but due to floating point errors in the math you're using in the pixel shader
I'd guess odd transforms are a big issue?
meh
i wouldnt say odd
but you're gonna run into floating point issues in any thing involving the gpu likely
(if your numbers get big)
anyway for me tilemap rendering traditionally was fine until i wanted to also render a large map with all of my other stuff as well (and running gameplay code, etc)
it was low hanging fruit
just a small update for you guys: my benchmark scenario is 707458 Quads rendered. with the normal sprite batch i get ~12.5 fps, with the reuse of the vertex buffer ~100 fps. Im really happy with it.
nice!
I'm making a purely 2D fighting game using LiteNetLib for networking. I am loading sprites in from textures. Do any of you know if there are any benefits from using monogame over Unity? I'm thinking executable size, platform compatability, performance etc.
why do you care about executable size?
The biggest factor that always makes me use MonoGame over Unity is having more control over everything. I always feel like Unity gets in the way of how I want to do certain things.
that is a loaded question that will spark debate.
you can make wonderful stuff in MG
i tend to push unity when you are doing something heavy in 3D
but champion MG for everything else
weird question: does Nez support rendering to a texture? I still want to use Nez's rendering stuff but I want to have a fixed resolution regardless of window size
is it a bad idea to override Draw()?
just depends on why you are overriding it
Hey all I need help with a math problem. I have a 3d rocket that's rotated to look straight ahead. I want the camera to follow the rocket. The mouse should turn the rocket, however, the rocket should always be moving straight. I'm using LibGDX for this and I haven't received any meaningful help in their discord
Does anyone know how I can draw a filled-in circle in Monogame, the same way I can easily draw a rectangle with the spriteBatch.Draw()?
a few methods, but all will involve a shader
How do I involve shaders?
either draw geometry yourself (quads here, so a 4 element vertex buffer) or spritebatch.Draw, both with a custom effect
but you can easily create a shader to draw a circle in a quad (simple polar math), or you can use an SDF shader, which may not look quite as good, but lets you draw several shapes with that
I see
What's a buffer?
Vertex buffer*
Compared to a normal vertex
And since it's a shader, I need to add an "Effect" right?
This extends SpriteBatch for primitives (rectangles, circles, etc.). I wouldn't say it's the most performant thing in the world but it's most likely adequate.
What Cobalt suggested would be much better, but I use this as a quick n dirty way of drawing circles (and other primitives).
I see, thanks!
Quick question though, do I just copy the Primitives2D.cs file into my project to make use of it?
Yep
I'm working on a fork of MonoGame. Is there a resource that explains what the different .sln and .csproj are meant to encapsulate?
such as?
@prime sigil a buffer is a collection of something (like an array/list). so a vertex buffer stores your vertices (on the GPU)
shaders = effects in monogame
Shaders being Effects in monogame explains a lot
Curious what the difference is between these two
When creating a new .fx
Why do shaders/effects only work when the SpriteSortMode is set to Immediate? (SpriteSortMode.Immediate)
Is there no way to have effects work when it's set to Back to Front, for keeping the layers of my sprites intact?
they dont
how are you applying your shader?
Like that
I'm using this tutorial
But it doesn't 100% work, I get different result sometimes
yeah you need to use spriteBatch.Begin(..., effect)
I see, will play around with it more, thanks
Yep, it works!
Another thing though, do you know why my sprite doesn't show pure red despite using float4(1,0,0,1) for the whole texture?
thats a multiplying factor
so if your color is 1,1,1,1 its gonna be 1,0,0,1, but if its 0.5, 1, 1, 1 its gonna be 0.5,0,0,1
What's strange is that every pixel in my ship sprite seems to be 1,1,1,1
For example, when I try to do grayscaling:
color.gb = color.r
It's as if nothing was applied to it
Nvm! I think I fixed it
The output by the default .fx template was: return tex2D(SpriteTextureSampler, coords) * color
but I changed it to: return color
And it works now
Hey guys! Does anybody here is using Monogame 3.8 packages from nugget? i was able to create a project, as well as build it, with no issues... But, my problem is with the Content Pipeline Tool. I've installed it trough nugget as well, and can open it with no problems. But it does not build SpriteFonts at all, complaining about FreeType6.dll missing. I've done some search, and found some people saying to install VC++ Redistributable, and i did, but no success at all. Anybody managed to get it working?
btw, i'm sorry if this is not the correct place to ask. First time poster here. 🙂
freetype is its own library
you can probably just google search for the dll
or find freetype's website
Hey @hot hazel, thanks for the reply. I've got the dll, and even inside the tools folder on monogame pipeline it's there, still, the pipeline seems to not be able to find it... I'll keep trying here, since, because of a weird texture bug on my graphics driver, monogame 3.7 is not that good for me, while 3.8 is...
TheLorencini gave karma to CobaltHex
copy it to the directory where your executable is
copy it to the directory where your executable is
@hot hazel it's there already...
even copied it to system32
very weird...
on 3.7, at least i could use the pipeline tool, but had the texture bug on the lib itself.
i guess i'll have to do some weird merge of the two (using 3.7 pipeline tool, and 3.8 dll filed)...
let's see
after all, 3.8 is not stable yet... can be some bug.
personally i use my own sprite font tools
personally i use my own sprite font tools
@hot hazel read some things about that, but never got the time to actually try it... Bitmap fonts seems to be a good way to go, since no matter the font i use, ttf fonts tend to be kinda blurried on my projects...
well id say use bitmap fonts
but roll your own solution
I think you need to install the 2012 .NET Visual C++ redistributable IIRC to fix the freetype6 DLL not being found.
why would you need the 2k12 .net redist
I think you need to install the 2012 .NET redistributable IIRC to fix the freetype6 DLL not being found.
@pearl ore .NET? I've read that the one that fixes this is the VSC++ 2012 redistributable... Even now, that i'm back on 3.7, i've had to install it.
Yeah you are correct, I wrote that with half my brain working. My fault.
does anyone here uses Ogmo editor 3.0?
I'm having problems, for some reason I can't save changes made to the project (like adding a new entity)
I didn't know where to ask for help so I'm trying here
#misc-dev or any official communication locations would be better
hey guys
wait
wrong chat
my bad
My dudes, I cant instal monogame directly on Visual Studio
Halp pls
gonna need more details
Hello, I'm having trouble creating a deterministic, fixed timestep game loop.
Here's a pastebin for how I'm trying to limit my # of physics steps to 15 per second: https://pastebin.com/TgVyDvib
The code displays the ticks per second to console every second.
What I expect is for it to always display 15. However, sometimes the ticks per seconds is 16 instead of 15.
Is the reason it's sometimes running an extra update per second due to rounding issues? I can't seem to figure it out
I'd asume some float rounding issues too.
you defenetly suffer from precision loss. Maybe do something like devide the System time with your time step.
@hidden shell its impossible to guarantee 15 updates per real second. fixed timesteps only guarantee that each step has the same length and it pauses between steps or run extra steps to keep it roughly in sync with the real time
the virtual time is what's updated in fixed increments
any good tutorial for monogame devs
look up xna tutorials
thanks
I know "don't ask" but, has someone experience with Aether.Physics2D?
Hi all, small problem, Was hoping somebody could help with. I made a dictionary<string, int> to hold player stats. Strings for the names of a stat and the int for the value of the stat. How would I go about modifying the dictionary values from another dictionaries<string, int> values? Thanks
@flat osprey dictionary["foo"] = bar;
but are you sure you want stats in a dictionary? you need to attach logic to them or they'll be useless
so unless you need a data-driven map between stats and logic, it seems more logical to make strongly typed stats
Yeh maybe i'm going about it the wrong way, I thought I could just use dictionaries to hold each races, class and players stats then modify the players values where keys match the race / class 's key
well you could, but you wouldn't get value from the dictionary if the number of items in it didn't differ a lot between objects
Mind if I pm just show what i'm doing as to not spam here?
so why not make a Race and Occupation class? they could then be referenced to define a Hero class for instance
might as well put it here, someone else might learn something
Well yeh, I made race classes and "class(like rogues, mage ect" classes that have 6 stats, Rather than running through them all to add to the players I wanted to store them in a collection so I could just run a loop when modifying the players stats
ok, sounds like you've defined new classes where you really just needed new data
So I want the player to have these stats all set to 0 then if they choose to be a human then all the human modifiers are applied and then they can continue to choose a race and then thats use to modify them
you can probably define 1 class to cover rogue/mage/etc
Well I made a race class and a classType class, Then with each race and class I made new classes than inherit from them because later I want to add more stuff to each of them, abilities ect..
i wouldn't inherit from them until it proved necessary
you want to focus on the data when designing a class hierarchy, much like when normalizing a database
from what i've heard so far, you have at least 3 classes. Race, ClassType(would swap this for Occupation to make the naming clear) and Ability
you might also want 2 Modifier classes, one for additive modifiers and one for multiplicative
and you'll need a class that describes the actual ingame entity, i usually name it Hero to avoid conflicts with Player(usually useful for controller mappings, etc.) and Gamer(often used for steam integrations and the like)
i also tend to have an Enemy class and have both it and the Hero inherit from an abstract Actor that's the base class for anything interactible
the actor could then contain all the logic needed to calculate effective stats from bonuses and modifiers
I get what you're saying but I don't know what way to handle the stats for each race ect.. What collection would be best for this situation?
doesn't really matter, you're probably going to pick the race from a list in a menu, so an array would work fine
i'd define the races in a csv file for simplicity, that way they diff nicely in source control and you can do mass-edits in excel
CsvHelper can do the parsing in a couple of lines
So for example just give the human an int array0-5, How would I pick out the stat though, Like I'd have to know what cell each attribute is supposed to be, This is why I was trying to use dictionaries because the key can be the name and value is well.. the value
Ah
i'd just put the base stats as columns, which means the race class gets a property for each
See this isn't supposed to be anything big, Just a small console game so I can practice programming.. Just realised.. Why not just create a database lol ffs
Appreciate you taking the time to help bud 🙂
yea, the csv files essentially becomes tables in a database. but there's a big advantage to using them over an actual database, since they diff nicely in source control
so you can do branches testing out balancing fixes and then cleanly merge them without conflicts
Hey folks! I have a quick question. I'm writing a game in monodev and it's an online multiplayer type deal. Does anyone have any good links on server-side collision? Any help would be much appreciated, I haven't been able to find much personally.
@pseudo sigil its no different from any other type of collision detection
how inefficient is it to make a draw call using a texture atlas like:
sb.Draw(texture_atlas, hitbox, texture_atlas.GetByID(1), Color.White);
as opposed to making a method with the texture_atlas that creates a texture from a selected region?
the sb.draw would be way more efficient if im understanding you correctly
well both are sb.draw
so I'm not sure which one you're talking about
what do you mean 'creates a texture from a selected region'?
I mean like
so the texture atlas is a giant Texture2D
I would have a method that looks like this
public Texture2D GetTexture(Rectangle source)
{
//code that takes texture_atlas and returns a new texture that is the region implied by the rectangle
}```
does that make sense?
like it crops out the section of the texture atlas and makes a new texture from it
my point is in monogame
new textures would be individual pieces of gpu memory
spritebatch, hence the name, batches draw calls i believe only by texture
so if you are switching textures, you lose all benefit
that is the purpose of the sourceRectangle in SpriteBatch.Draw
so it would take less memory by certain
what about gpu power though?
if you create two textures
when you draw something it has to bind that texture
then if you wish to draw a second texture it has to bind that
(in addition those are multiple draw calls)
modern dx/gl can do bindless textures, but i dont think monogame supports that and i dont know enough to talk about that
its basically no different from rendering a 3D mesh with a texture
the reason atlases exist is to be faster and smaller than individual textures
so hands down it's faster
awesome
thank you!
also easier
definitely
thanks @hot hazel
Osuology gave karma to CobaltHex
anyone have experience with debugging opengl shaders for monogame? getting program crashes when certain shaders run, and theres no debug output
figured it out. unless im doign something special, one cannot have more than one position per vertex
you can have multiple uv coordinates and other features, but multiple positions makes no sense
Dx supports them, I was using for misc vertex data
I guess the question is should I put the stuff in a texture instead
ok so this sounds weird but I want to have a 3d rendered item in a 2d space
like, it's only a visible difference to the viewer
Everything on a screen is 2d
Gonna need more details of what you want
so for example
floors and stuff are 2d
but walls are 3d
like pretty much everything but walls are 2d
actually I'm just gonna figure stuff out on my own and be less dumb with questions
hello
i am interested in the ways of the monogame™️
i've seen some few code bits and some unity knowledge transfers over to here
is it true?
do the same barebones rules mostly apply to both
monogame is only a framework
so while it does provide some things like a simple model renderer and spritebatching it doesnt require you use them and they are otherwise pretty barebones
it doesnt really dictatate how you build anything
so anything you did in unity you'd have to do in monogame
but you'd also have to do most of the stuff unity did for you
@flat orchid I prefer Monogame over Unity because I have so much more control over my project. A big downside is that there’s no GUI. It’s just code
So it’s up to what you prefer
Wdym there's no GUI?
@raw warren
No integrated UI library?
No no
There’s no gui for the person working on it. Like how Unity has its workspace. You just type code into your IDE (I recommend VS). You don’t drag and drop assets or anything of that sort
Kyle Schaub has a great tutorial on Udemy that covers both C# and MonoGame
Hope that helps @flat orchid
Keep in mind that MonoGame is primarily for 2d
Unity is better for 3d, but not so great for 2d
you can use monogame for 3d no prob
again, you'll be doing 90% of the work yourself however (or find a library)
Well yeah
It’s just more efficient to use Unity
i wouldnt call it efficient
just easier
hey guys i just got started with MonoGame this weekend, are there any good tutorials for how to change scenes? like from splash screen to main menu?
monogame/etc dont dictate anything about how you do that
e.g. my game does not use scenes
so its up to whatever library you're using really
@gray matrix what you're looking for is documentation on how to manage game states. A simple version would be having a class for each state(scene) and call update/draw on it through the Game1 class
the update method could then return a string/enum indicating the next state to switch to and then do a switch statement that swaps out the active state in the beginning of Game1.Update
its important that you only swap states in the beginning of update though, otherwise you might end up drawing a junk scene that hasn't been updated yet
wait what? are you saying i should be using the same Game1 class to render ALL my stuff with just different game states?
in my game i have a map class thats basically the game renderer
it itself is just a UI component
my main class renders the UI and the UI can update what UI is drawing
so they UI could be menus, the game, the editor, etc
Long life libgdx...
good article
just realized this chat isn't for unity/c# lol
What would you say are some things that could be improved in libgdx?
This is not a channel for advertising
@hot hazel Sorry I didnt know.
hello guys
any libgdx clevermind?
!justask
Hey guys! I have a question related to Monogame and Unity, I thought asking here would be the best place, do let me know if it's not :P
I am a decent programmer with a decent background and I recently started my own game project. Game development terms and structure is not unknown territory for me, however it is my first real game project ever, while intimidating I still feel confident about it 🙂 We're making a multiplayer 2d game with a top-view camera.
As the lone programmer of the project, as of right now (In the process of getting a second one), I am faced with quite a difficult question which is "Should we use Unity or something like Monogame?". I've read alot of articles, reddit posts and messed around with both Unity and Monogame. However, I'd like to get a more direct input with my situation in mind.
We've been using Unity for the past month or two, however my feeling is that Unity is taking care of a lot of things for me in a way I don't necessarily like, but also brings alot of tools to facilitate the workflow between programmers and artists as well as making things easier for me. As I'm working with pixel artists mainly using Aseprite, using Unity's built-in tools to process spritesheets and create animations has been a charm as we were able to quickly see results in a somewhat playable state.
While this aspect is great, as a programmer, I'm feeling forced to follow Unity's pattern which I don't necessarily like and Monogame definitely allow me to do whatever the hell I want and ultimately, gives me a lot more control as to what's going in the game compared to having to work with Unity's pre-made abstraction.
While that last paragraph would totally convince me to use Monogame over Unity, my main concern is the workflow between programmers and artists and the overall additional dev time required if I go with the monogame way. What is your guys opinion on that? Have you ever been faced with this situation or ever thought about it?
Thanks 🙂
A good analogy I came up with while thinking about this whole thing was "Do we want to use a lego box with pre-made parts that we only need to connect together or do we want to take the massive box of regular legos"
is it possible to do webapi calls using monogame? trying to figure out if I can port some server stuff from gms2 to monogame
@raw warren depends on the game, it's possible to have monogame be the quicker implementation option. but you do need to know what you're doing
and given that you're looking for a second programmer and asking this question, you probably don't
That's quite the harsh answer to reply with "You need a second programmer so you don't know what you're doing"
unity is no walk in the park either though. it takes strong management and a disciplined team to work efficiently with it
And the reason i'm getting a second one is because I can't do all the work alone honestly, a second mind to think about things and figure out stuff as we go on is always better
that's not what i meant, i was commenting on the fact that you're looking for a programmer and you don't have the answer to the questions posed here
Ah! I understand now, sorry about that assumption.
With that aside though, I agree, Unity is no walk in the park either, I don't expect Unity to be easier in fact.
its also very important that you get the right person for the job, or adding another head is only going to slow you down
conversely it also means you need the skills to work effectively with a team
Which is understandable, and I totally agree. I'll keep that in mind for sure. If we take the second programmer out of the equation however, what is your take on my concerns? Would you recommend one over another?
for a solo 2d project i'd lean towards monogame, simply because you can get stuff done well in it far quicker
unity is better suited for teams of 5-10 ppl
Interesting take, I never thought about the team size being a factor of what to choose honestly. I do have a couple people with me focusing on art since the project will require a lot, with that in mind, Unity would be a wise choice to keep that workflow clean I assume. My main concern however, since this will be a learning process for me on making an actual game (I've only made mods for existing games so far), is that using Unity may not allow me to fully understand how my game would work and not entirely having control on it.
I feel like this is a decision between "Controlling my code" and "Having great tools out of the box"
your artists shouldn't be directly interacting with the engine while they work. The should be sending their assets into the pipeline and the rest is up to you pretty much
unity doesn't have "great tools" it has lots of "good enough" tools. which is why you can work quicker with monogame, if you know what you're doing
unity was designed around a process where decisions are made ahead of time in a meeting, followed by 1 or more teams spending a day or 2 implementing the decision into the game. That's not a quick workflow for a small team
Now that you mention it, I do see that process in Unity now, hence why I felt like the code I was writing wasn't really "satisfying" if that makes any sense. I do see the upsides of Monogame alot more now, when starting out I assume I will write a lot of code to get the game working but in the long run, implementing new stuff would be easier since all of the code will be for my game and only my game compared to Unity which targets "A game in general". Correct me if i'm wrong
And "Good enough" tools is indeed the right term 😛
well monogame just brings you to a lower level of abstraction, so you can implement your game using conventions and policies as opposed to hand-tweaking individual attributes
which means 1 man can do what it normally takes 10 people to do. as long as he knows what he's doing
but it also means you can't throw resources at a problem to make it go away
That makes sense! Thanks for your insight, it was very helpful, I know what I'll be studying from now on 🙂
thanks @quiet ibex
Raphy gave karma to Ragath
I'm definitely open to more opinions should anyone else want to throw their 10 cents as well 🙂
2 cents?
following along ragath's statement
unity provides a lot of things for you
however if you want to do things differently, you're fighting unity
monogame does less for you, so theres less to fight
so it really depends on if unity works the way you want it to
Thanks @hot hazel
Raphy gave karma to CobaltHex
how to change window size? (libGDX)
I'm working on a space game, I have a problem with the planets and the star moving during warp. They both use the same class for movement but somehow only the first of them that's being updated moves
I fixed it
how to change window size? (libGDX)
@raw warren buy 4k screen
@raw warren buster
the Lwjgl3ApplicationConfiguration has a setWindowedMode(<width>,<height>)
@distant perch HOW?
i need example, i really dumb in this damned api
your talking about the size of the window when running as a desktop app, right?
yes
but i want create app for android
so you probably have some Lwjgl Launcher class that looks a bit like that:
public class Lwjgl3Launcher {
public static void main(String[] args) {
createApplication();
}
private static Lwjgl3Application createApplication() {
return new Lwjgl3Application(new YourGame(), getDefaultConfiguration());
}
private static Lwjgl3ApplicationConfiguration getDefaultConfiguration() {
Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration();
configuration.setWindowedMode(1234, 123); // <- where you can set the default window size here
return configuration;
}
}
i talking about libgdx, man...
I know, that's the class that launches a libgdx game
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
BRAINCRACK
how does "DesktopLauncher" look like
package com.mygdx.game.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.mygdx.game.Drop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new Drop(), config);
}
}
well there you go
oh im stupid
add
config.setWindowedMode(something something)
ok i understand
facepalm
😉
@distant perch the configuration has only 2 setters
try
config.height = 480;
config.width = 640;
frameworks are too complex for my brain
@distant perch this works
thanx man you have quantum brain
if you want to change the window size while the game is running you can also call
Gdx.graphics.setWindowedMode(width, height);
but since you mentioned you wanted to code for android as well I would check before calling that if it's not on android (changing the window size on android doesn't make much sense)
if (!Gdx.app.getType().equals(ApplicationType.Android)) {
Gdx.grpahics.setWindowedMode(width, height);
}
also works
where do you learn about all these methods?
just playing around with it and if I'm stuck, asking people on discord
but the libgdx wiki is not too bad https://github.com/libgdx/libgdx/wiki
@distant perch okay, thanks)
DannyWarp gave karma to this_is_phil
I need help
if you look closely(might be too bad resolution) the planet vibrates when I move. You can se the stars flickering in the lower left. I don't understand why i vibrates. I can provide the code for the movement
@lone radish that's because of improper handling of subpixel positioning
What now?
I am rewriting the whole thing tho
I am making it a render target instead
you probably had a blurry render and then set the samplerstate to pointclamp
I was printing it directly to device
a pointclamp samplerstate is not good enough to deal with this on its own
But I have another problem now
Wait
Tell me about the subpixel thing @quiet ibex
@lone radish basically the pointclamp filter can make pixels disappear if you try to draw them between screen pixels
its also why it looks like the thing vibrates
I don't use a samplerState at all
The planets don't vibrate anymore but the stars do dissapear from time to time
What should you do in this case?
I think I have the same problem
I don't know if it's visible enough but when the camera moves in a horizontal or vertical momement it's ok but not with diagonal movement
@dense sable there's no one size fits all solution for this sadly, one option is to render different things on different "pixel grids"
i've done that in a game where the camera is fixed to the player and the rest of the world is rendered to a render target that's then aligned to make the camera movement completely smooth
the player sprite can be positioned between 2 background pixels in that case though. so it's not a pixel-perfect render
I'll consider using two different render targets, but I don't really see what to do to have a smooth camera movement
i feel like now it's just doing ←↓←↓ pixel by pixel
I think the idea is that you can move the render target at partial pixels, but it may look blurry so only use it for the backgrounds
I recognize that name...
Anyway, one simple solution to this week-old discussion is just to always render everything at exact pixels. Just... round them off.
Intuitively it would make things jitter but in practice it looks good.
@orchid perch no that's what he has and it does noticeably jitter
it's just such a common problem, that people go "omg, i didn't know things could look this smooth" when you get it right
Yeah.
Jittering means you're either jumping back and forth, or in pixel steps of alternating lengths.
If everything is floating point and you only floor it for the final render it usually works out.
My suggestion is always if you're making a pixel-perfect game to work in pixels. I actually am using integer position values at all times and I think I got the motion right. Could do a write up on it.
after joining a game jam and realizing with horror that I had no idea how to architect a game I looked into some ways to structure a game; libgdx comes with an entity-component system plugin that I'm currently playing around with but I have a question: components are supposed to contain "data" and not "functionality".
But how strict is that? in Kotlin, which I'm using for my playing-around, functions can be treated like data. It's cute, but is it "actually" data? What happens if I put a field for a function from say, integers to integers into a component's constructor (not as a method, just as raw data)? What goes wrong? Does this kind of thing have undesired side effects? And if there is a channel to ask questions in better than this one, which one is it? Thanks!
In general, most ECS's don't literally enforce the data-only components, but it's in the purpose of the ECS design itself that components be only data so they have as little overhead as possible.
In concept, data is simply values that are stored. floats, ints, bytes, data that's read/written to.
I'm not sure what you mean by functions getting treated like data, unless you're talking about delegates/function pointers. In which case, yes, in theory, a delegate/fp is just like any other data, and will be modified/reinterpreted in undefined ways if you treat it like other data types. However, there's nothing inherently wrong with passing those around.
@timber mesa when you bundle logic and data, you end up eliminating the reusability benefits of the ECS
Hello everyone, I am new to Youtube and I just uploaded my first video, https://www.youtube.com/watch?v=zbGm5PevWyA support me in this new project and be part of this new project that begins
https://cdn.discordapp.com/attachments/625720247667916820/787650528673792001/unknown.png
How can I fix this error please?
can you translate that to english?
The imported project [path] was not found. We have also tried to find [Path] in the rescue path for [path]. Theses search paths are defined in [Path]. Check if the indicated path in the <import> declaration is correct and if the file exists on the hard drive in one of theses search paths. [Path]
@hot hazel
Try reinstalling monogame, or use the nuget pkg
I highly recommend libgdx. I'm writing this game with it now.
Love the visual aesthetic of your game @fossil mesa The tower looks dope
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); that is loooooooooooong
that tower looks nice
That's just the graphics from Stardew Valley though...
Yeah, they are useful for prototyping.
im newbie to monogames
Does anyone know a good tutorial for Tower defence games in monogame?
I don't think there is a tutorial specific to tower defence, but if you look for XNA tutorials you will find a lot. Most of the stuff described for XNA still applies to monogame
the monogame documentation lists various sources for tutorials as well
Thanks
@marsh palm it's tough to find tutorials for specific games and tech combinations. but you should have no trouble finding info about how tower defence games are constructed and then you can more easily look up how to do the specific things in monogame
Hi guys, sorry, maybe my question is not for this channel, but I can't find where I can ask )) So I am Manual QA Tester and now testing games based on libgdx and want to start automate my tests and don't know which tools I can use for it, I saw many tools for mobile automated tests but idk is there match for gaming, if you can give me advice or provide to the right channels it will be very helpful for me )))
You might need to create an interaction layer that allows you to simulate inputs within the game and use a standard automated testing suite.
@glacial hull if you want the test to be more than a glorified keyboard macro, you're gonna have to talk to the devs and establish an architecture that allows for testing
and it's usually not viable to replicate an entire testing session with some scripts
Yep also think about it, thank's for advice
has anyone worked with fmod in monogame? if so, any tips/guide/info on setting it up and getting it to work?
any reason you want to use fmod in particular?
does wwise work easier?
if wwise has a specific solution for monogame then sure
is what monogame provides not sufficient?
for audio?
no
most engines have really lackluster audio solutions
and even if it did have a good one, i'd still be using fmod
well i imagine fmod is like using it anywhere else
im pretty sure someone has written a .net interop lib
yea let me find that
i found a solution on git
apparently there's a small bit of fucking around with this
but it should work(?)
I'm using FMOD with MonoGame and I used the aforementioned github link. However the latency is awful :(
Oh. wait. I'm actually not using that link. I started using that, but I switched to the FMOD c# bindings when I wanted to decrease the dependencies of my project. The FMOD installable api includes the C# bindings.
why this though
like
this is from the tut, i'm telling it to search in content yet the command goes through nectoreapp31
oh i just needed to build lol
N I C E
it works
@frigid fiber how do i link an fspro project to monogame now?
i'm guessing you've managed it
@flat orchid You have to build the .fspro (F7, I think) from FMOD Studio. Then it generates 1 or more .bank files.
Then you use FMOD.Studio.System.loadBankFile () to load those .bank files
thanks a lot @frigid fiber
Subdivisions X-1 gave karma to Kak
Is there an easy way of getting MonoGame to work with MonoDevelop?
In what way?
download the monogame api and import that in monodevelop
sounds like it makes sense
or nuget package(?)
if monodev has those, idk haven't used it
can also clone it off github/download release
you just need to link in the assemblies
MonoGame is integrated within MonoDevelop, but it's broken
that's why I was having issues
i use VS, but don't use the integrations, I just link it from nuget
yeah it works fine with VS on my old laptop
but my new laptop is running ubuntu
so I just didn't know if anyone had an easy fix for it
that's all
does nuget not work?
I'll give that a shot
I'm not sure how that will interact with the MonoDevelop that's already there
I think it prefers the nuget versions but either should work hopefully
@raw warren guessing you're using the Linux version of MonoDevelop? it's about a decade past it's expiration date, unless someone picked it up after xamarin
vs code might be sufficient
ok
thanks all for the help
i started using monogame today and it's gotten me to learn a lot about how it works further down to the metal
very refreshing
@formal basin And is Monogame more beginner friendly then unity in general?
not really, but if you want to get into it from unity you'll recognize a lot of things from unity's basic scripting functionality
How do I add Monogame build targets to Visual Studio?
do you want the content pipeline or just monogame?
Hi, I have a question about libGDX. To make a long story short, a few months ago I found Unity very limiting and I switched to libGDX and it's really great. I love the code freedom and cleanliness. I want to continue to develop in libGDX, but there is one thing that concerns me the most... Is it possible to make a good looking 3D game using libgdx?
what you think?
assuming it lets you create your own shaders and supports e.g. multiple textures, then yes of course
it will be a lot more work to make it look good over what unity provides out of the box however
technically it allows us to create shaders. There is even some shader lib. But this still looks poor compared to the default Unity scene... So I wonder if there is any good looking game made with libGDX which I could refer to as a proof of concept?
For me Space Haven is so far best looking game made with libGDX, but is 2D and completely different art style
How to build game in visual studio using monogame ?
Hey fellow MonoGame developers, I have a real puzzler for you. The first (and rarely, also the second) time that I start my game every hour or so, nearly all of my textures are black. I'm loading my textures from a packed spritesheet created with TexturePacker, and from what I've noticed, the only images that load successfully are from one specific folder: images/entity/monster. Here are some images so you can see what I mean. This is a very difficult issue to debug because after it happens once, it takes around another hour before it will randomly happen again.
I'm really stumped on this, so any tips at all would really be appreciated. This happens no matter how/where I run it, as far as I can tell
you just have to comb through your code for bugs, make sure everything is meticulously planned out and work exactly as intended
It seems a nice game, I didn't know it at all. I will add it to my Google Sheet of (mostly 2D) indie games sorted by engine used: https://docs.google.com/spreadsheets/d/1z1RV6w4HjPODFcao34h72Vw-9KxtQ9rv0ZM7folTUMU/ 😉
Hey everyone,
I do write a game and do use a entity component system model for this
I do have the following parts for the core of the structure
EntityManager
ComponentManager
EventManager
And a wrapper to get a central access point for everything.
Now I was thinking how I could use UI to show data to the player because the gui is not connected to the ECS right now and everything I read told me better don't enforce the gui system into the ecs. My idea was to register the gui elements into the EventPipeline and push status changes throug the pipeline to the display.
What do you think about this approach?
I would create a "GUISystem" which catches those events updating the gui data. But since the gui is not using the rendering system from the ecs it kind of breaks the idea of a central system which manages everything.
https://pastebin.com/9x5dA7Vf <- Button
https://pastebin.com/ZQQaYAts <- underlaying class
https://pastebin.com/26E0PEDd <- if you want to go deeper
https://pastebin.com/FewznHv9 <- another class to go deeper
All ui elements are build on this base
What is the purpose of component manager?
@orchid frigate you seem to have a lot of indirection
also a lot of your doc comments leave more questions than answers
I do use it to manage the components for the ecs
It also does pool the old already used components so I can reuse them to prevent the gc.
That the docs are missleading and not really helpful is bad,sorry I do need to improve it.
Do you need more information?
Yep I do need to refactor this as soon as all the GUI elements I need are written
Components are typically structs, if you're storing in an array that shouldn't be an issue
I do store them in a list one for each type to increase the performance 👍
But still my question to seperate the GUI completely from the ecs is this a good one?
Not sure how to integrate it into the ecs otherwise
while some composability is nice in a GUI, it doesn't really make sense to have it as a proper ecs imo
its very hierarchical
if you want an ecs for your gui id say it makes more sense to have your gui itself be its own ecs, and then if you need your entities in game have components that refer to entities of the GUI
as they don't have any overlap otherwise (your UI entities should data bind with the game but that should be the extent of the relationship)
Thank you very much I will try to implement this 👍
Me over here using his ECS for his GUI like: 👀
doable, but not sure its worth the complexity
How difficult would you say learning monogame is compared to other frameworks like pygame, and if it is more difficult what features or unique attributes does it have that sets it apart form others like pygame. Lastly, I noticed that monogame has sort of a structure to it ( a separate function to load, draw, update, etc.) how does this impact development with it compared do other frameworks that don't have this, for better or for worse.
monogame just provides you with the basic abstractions so you don't have to worry about things like creating a window, interacting with graphics api (dx/opengl), etc
and provide some helpful helpers (math library code, model/textures/etc)
beyond that, it's all up to you
its not an engine
the load/draw/update/etc that it provides are optional
@sage quest it impacts your development a lot or not at all, depends on how you use it. But it sounds like you don't know C# so if you read up on that, you'll start to figure out what really sets it apart from things like pygame
what's up LIBGDX FAN CLUB 😂
last week, there was the good ol' libgdx game jam that i know lots of you participated in.
i did too, and i submitted a very 'cool' tech demo that demonstrates some basic networking/multiplayer capability.
what's especially cool, is that you don't even have to play it, and you can just read this awesome blog post i wrote about it:
https://developer-doge.itch.io/alice3gdx/devlog/237461/the-trials-and-tribulations-of-networking-a-basic-browser-game
cheers!
soo, do i really need to use SpriteBatch for something like drawing solid color rectangles on the window/game
what else would you want to use?
or more to the point: why not use spritebatch?
just based on what i saw in monogames documention, spritebatch is used for actual sprites, no?
well, it's for pretty much all things 2D
oh
spritebatch abstracts the whole concept of drawing 2D graphics within a 3D renderer so you don't have to take care of texture positioning beyond a 2D plane
it is put together as a batch of graphics in order to have it only create one object to draw for the graphics card instead of creating a draw call for every single sprite
so you draw your 2D sprites / textures / text into a spritebatch (or multiple if necessary, iirc there is a call limit), the spritebatch then combines it for you into just one image and sends it to the graphics card
yeah i got it
the alternative is to build quads (two triangles) and render those yourself
but thats basically what spritebatch is doing for you
Type parameter 'T' cannot be instantiated directly
anyone know what am i doing wrong?
: new()
After the class decl before {
?
Sorry, where T : new()
Google generic constraints c#
this is java D:
i had to do it for school D:
(sorry i just saw this, and this exchange is freaking funny as hell)
afaik there are generic constraints in java
generics would be useless without constraints
:0
Less useful *
so the google keyword i'd use is "java generic array instantiate"
but honestly seeing the results point to reflection is discouraging
so rather than doing new T[][] i should pass in an existing array?
i think array is maybe not what you want to use in java for generic typed collections
@hot hazel no you can't actually do anything without constraints, but typically you have a few implicit ones built into the language
?
Hi you can watch my video I am developing a dungeon puzzle game
https://www.youtube.com/watch?v=XVcWQxfNgS0
why?
Hey, looks great! Where will you release it? (Steam, itch.io, Game Jolt...)
Hey, thanks. While an alpha version for android in googleplay is planned. At the moment I am drawing the environment. Subscribe to me instagram @wad_code
W A D gave karma to Pabeio
Very cool! Do you think you are going to release it for computer too?
The mobile version is smoother, and of course
Great!
Stay tuned for updates and news!
Ok! Thank you, and good luck with your project!
Thank you too
W A D gave karma to Pabeio
Thank you
No problem
@raw warren
Yes
People here
it's a bit of a ghosttown...
Understandable
monogame
the big ded
dead
Hello
ded
I still do monogame stuff, but I never really have to ask about anything.
Monogame is so simple, there aren't really many questions coming up about it
same. The monogame discord is so active that any questions I have I can get answered there
<@&133522354419662848>
monogame is an open source continuation of the XNA framework.
XNA is a freeware game development framework that microsoft used to publish back in the xbox 360 days.
@little moat thoughts on monogame for webgl?
Monogame for webgl is the reflection of a project that is a management disaster.
650+ bugs reported with none fixed during months, incredibly interesting PR with things like compute shaders or geometry shaders which are completely ignored by management, and one of the maintainers decides to incorporate a new platform which nobody asked for and for no real reason other that "look my lame 2d game runs in a browser with major bugs" with a technology already obsolete the moment they shipped it.
<@&133522354419662848> scammer
<3 thankss
Could I get a link to that?
idk about anyone else but I keep getting notified that this channel has unreads
is there some sort of component-based game object library for monogame?
a quick google search reveals one here: https://www.monogameextended.net/docs/features/entities/entities/
oooh thanks @hot hazel
Technostalgic gave karma to CobaltHex
wasn't really sure exactly what search terms to use
It's from spam messages that got deleted.
If I'm looking for a 2D rigidbody physics engine to use with monogame, what would you guys recommend? I've only really seen Farseer physics recommended for c# online but I've used that in the past and I remember having some issues with it so I'd prefer to use something different. Does anyone have suggestions? I think I'd prefer to use something written natively in C# rather than a port, but I'm still open to using a port as well. Thanks in advance!
What is the issue you were having?