#monogame-and-libgdx-dev
1 messages · Page 3 of 1
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
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
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
also easier
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
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
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)
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...
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.
!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
the Lwjgl3ApplicationConfiguration has a setWindowedMode(<width>,<height>)
your talking about the size of the window when running as a desktop app, right?
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;
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)
😉
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);
}
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
@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?
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
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
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
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?
(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
it's a bit of a ghosttown...
Understandable
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.
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?
AetherPhysics is based on Farseer but has been improved quite a bit in the last years and it's still maintained (last version was released 9 days ago)
The first step is removing all
Microsoft.Xna.Framework.XXXreferences and replacing them with references toMonoGame.FrameworkandMonoGame.Framework.Content.Pipeline. This is required as you will no longer be building against Microsoft XNA.
I'm getting a lot of build errors
this is incorrect
You keep the references to Microsoft.Xna.Framework because that's the namespace Monogame uses to maintain backwards compat with games originally written in XNA
(for the record, FNA does the same technique)
MonoGame.Framework has a few extra tidbits that Monogame has added to the framework for additional functionality. It does not replace the Xna Framework namespace
Whatever guide/person told you to remove Xna Framework references is misled
Hi! does anyone have a link to learn about reading data from json or xml in monogame? I'm trying to read in some meta data for a sprite made in Piskel. I loaded the xml in the content pipeline but I cannot find any doc on how I would then use it
you can just read xml or json directly in c#
system.xml iirc and Newtonsoft.Json (or if you use modern c# system.text.json)
@dusty drum ill show you how i serialize and deserialize object data with xml
first, your object cannot have a texture2d in it, texture2d cannot be serialized (i believe possibly color arrays can be but its usually not something that games do) you load your entire textures into content as usual
so you create a new class that contains the data that you want to save in xml, this class will not perform any actions it is only a base for your objects data, something like this
public class EnemyData
{
public int enemyID;
public int enemyHealth;
public Vector2 enemySpawnPosition;
}```
now at the top of your main class (or whichever class you build your enemies, etc) you need to include xml in your project
```using System.Xml;
using System.Xml.Serialization;```
in your main/world class you build the serializer and the empty object
EnemyData enemyData;```
initialise this serializer with the EnemyData class we built
```enemyXml = new XmlSerializer(typeof(EnemyData));```
so now you most likely dont have a file to read so we can write an xml file to your desktop, make sure you run this part only when you want to create a fresh file or save over a file
``` TextWriter writer = new StreamWriter(@"C:\Users\PC\Desktop\EnemyDataFile.xml");
enemyXml.Serialize(writer, enemyData);
writer.Close();```
this xml file will be plain text since we didnt encrypt it so you can now open the file as a notepad file and edit the int, vector2 or whatever other data you make your object have.
and now read the data from the file wherever you have it located into your enemyData that you declared
```TextReader reader = new StreamReader(@"C:\Users\PC\Desktop\EnemyDataFile.xml");
enemyData = (EnemyData)enemyXml.Deserialize(reader);
reader.Close();```
so basically if you now create a new class called enemyObject you can make it inherit all of the data that enemyData is holding
```enemy1 = new enemyObject(enemyData.enemyID, enemyData.enemyHealth);
enemy2 = new enemyObject(enemyData.enemyID, enemyData.enemyHealth);```
but the real strength of serialization is by creating a list of data, so you could store many enemies, objects on the map, level editing data, inventory data, all read from and written to a single file the same way we read any data
@dusty drum if you want a bit of help on how to implement it in your specific use case let me know
ah great thank you so much @frigid dagger
talis thanked Melt
I do have a question regarding the content manager, you reference the xml by full path-- what if this was an android game? I'm new to monogame, but assumed that was the purpose of the content.mgcb file. I see it is able to build with the xml file, but I'm not sure how I would reference that in a stream reader
the use case is the sprite editor I am using, it can export meta data as a text file. like how many frames, dimensions for each frame etc. this way I can display the sprite from a sprite sheet the editor created
maybe there is a better way to do this though
Many people ditch the content mgcb in favor of their own content loading system (as mgcb is... Pretty bad). You can add resources to your game via a data path and then reference them via relative paths
@dusty drum so for reading the image data im not too sure what you load the json metadata into.
when i read my image data i make an image in piskelapp and export it as a spritesheet
and i read the image into my own data object which has image XY positions and number of frames and framesizes etc
so i read this notepad information and it spits out the positions of my content
and i can modify it at will on the image or in the data
are you manually creating that xml?
i looked at the json metadata and it stores a lot of different fields in it
{"frames":{"New Piskel0.png":{"frame":{"x":0,"y":0,"w":64,"h":64},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":64,"h":64},"sourceSize":{"w":64,"h":64}}},"meta":{"app":"https://github.com/piskelapp/piskel/","version":"1.0","image":"New Piskel.png","format":"RGBA8888","size":{"w":64,"h":64}}}
i suppose you would need to make an object that can store that data and then read it straight into your project
yea i just write the numbers into each field in the xml based on the image i create in piskel
its definitely not as streamlined as exporting the data from piskel and importing it back. but this way i get to just play with the data i want
ah okay, makes sense
yea so i would suggest just finding what object you need to build in your project that can deserialize the data into
but its very worthwhile just making a simple object that stores coordinates and sizes of your images
and then for things like my map builder i launch a map builder project and import all my images then when i place one of them in the blank map i save its location to xml
and read that xml in the live game
so for placing maps you dont even need to open the raw data or change it manually
ah that's a good idea, yea ill have to build a little editor at some point
yea good luck with your next mission, i was probably a bit vague about some things so i can clarify on something if you need but hopefully youre closer to a solution you want 🙂
How can I prevent monogame from rebuilding my assets each time I run the game ? Like he builds my font every time I run the game and it takes time ...
with mgcb? Those should be precompiled once in the mgcb editor (or just toss that out and spin up your own asset loader)
hi
stop trying to shag my dad he doesnt want you
ye
he is a good man
he doesnmt want you
@grizzled forge are you ok?
Is there a way to make the monogame content builder use local paths instead of full paths? Every time I switch computers I need to commit that change to version control because the path changes
Edit the project files and see, I don't use mgcb but everything was always project relative for xna
what's up cuties. i know this is late, but libgdx had a game jam this week: https://itch.io/jam/libgdx-jam-18
the best news: it's already over... and you get to play everyones games!
specifically, my partner and i created a 2d puzzle platformer. it's playable in the web browser... and it's really hard.
lettuce, or any of the libgdx-ers what you think about the submissions!
https://github.com/tehnewb/LibGDX-Game-Library
Gimme some stars 😉
added some projectile tracking if anyone cares: https://www.youtube.com/watch?v=nssJOMD1pYk
This is a pixmap utility that can be used to create a clone of a pixmap with a different alpha, to create an outline of a pixmap, to create a shadow, and create a light
hi
how can i parse specific textures from a texture?
i got the thing that controls textures working
i just cant do the algorithm
this is an example sketch i drew to illustrate what i will do in one dimension
same for the y
if(x == spritesX - 1)
{
var textureToAdd = TextureRegion(sheet,
((spritesX+spaceBetweenX)*spritesX)-spaceBetweenX,
((spritesY+spaceBetweenY)*spritesY)-spaceBetweenY,
width,height)
SheetAssets[nameToConvert]!![keyToAdd] = textureToAdd
}
else
{
var textureToAdd = TextureRegion(sheet,
((spritesX+spaceBetweenX)*spritesX),
((spritesY+spaceBetweenY)*spritesY),
width,height)
SheetAssets[nameToConvert]!![keyToAdd] = textureToAdd
}```
this is the code i wrote for this
ignoring the fact that this assumes that the textureregion uses bottom left point
this only shows this single texture in this spritesheet
(dont know if i have to credit here but https://kicked-in-teeth.itch.io/button-ui)
soo, what do i need to write as algorithm for this?
fun loadSheetAtlas(directoryToSheet: String, names: List<String?>?, width: Int, height: Int, spaceBetweenX: Int, spaceBetweenY: Int, spritesX: Int, spritesY: Int)
{
SheetAssets = mutableMapOf<String, MutableMap<String,TextureRegion>?>()
var nameToConvert = Gdx.files.local(directoryToSheet).nameWithoutExtension()
nameToConvert = nameToConvert.replace(' ', '-').toLowerCase()
var sheet = Texture(directoryToSheet)
var nameIndex = 0
if(!SheetAssets.keys.contains(nameToConvert)) // to see if we have parsed it already
{
SheetAssets[nameToConvert] = mutableMapOf<String, TextureRegion>()
for(x in 0 until spritesX)
{
for(y in 0 until spritesY) // when i put a -1 to spritesX/Y the keycount becomes 121 for 12,12?
{ // I check for if names is null every single loop, can be optimised to check for once but that'd be premature optimisation
var keyToAdd = if((names != null) && (names[nameIndex] != null) ) names[nameIndex]!! else nameIndex.toString()
if(x == spritesX - 1)
{
var textureToAdd = TextureRegion(sheet,
((spritesX+spaceBetweenX))-spaceBetweenX,
((spritesY+spaceBetweenY))-spaceBetweenY,
width,height)
SheetAssets[nameToConvert]!![keyToAdd] = textureToAdd
}
else // these will work if textures use bottom left origin point
{
var textureToAdd = TextureRegion(sheet,
((spritesX+spaceBetweenX)*spritesX),
((spritesY+spaceBetweenY)*spritesY),
width,height)
SheetAssets[nameToConvert]!![keyToAdd] = textureToAdd
}
nameIndex++
}
}
}
}```
ignore the comments
this is the code i currently have
lateinit var SheetAssets: MutableMap<String, MutableMap<String, TextureRegion>?>
outside the Assets object
this function is within the assets object btw
so to summary
how do i parse standalone textures from a spritesheet
like the algortihm of it
help
Are you just trying to split the sprite sheet so you can extract specific images?
TextureRegion has a static method called split(tileWidth, tileHeight)
TextureRegion.split(int tileWidth, int tileHeight)
it's a 2D array
If you're trying to split the sprite sheet and then assign things names, you can use the GDX Texture Packer -> https://github.com/crashinvaders/gdx-texture-packer-gui/releases
@crimson yacht
the problem is that there can be a bit of distance between textures ( absolutely not for between textures and borders thought)
so, you're wanting to assign each texture a specific location you can pull from?
because some have different padding between?
i've thought of using an atlas but i deemed that it is too difficult for me to integrate it into my project as
- dont know java
- they are in different directories
what?
So, you have a sprite sheet with images that all have different lengths between them, right?
something like this
yes
like this has a padding of 0
Looks like all of those GUI elements have more than a padding of 0
are you using LibGDX?
yes
black bars are borders
but still, a good candidate for applying padding
GUIPack.png
size: 647, 558
format: RGBA8888
filter: Nearest, Nearest
repeat: none
Empty Button
rotate: false
xy: 0, 0
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
Play Button
rotate: false
xy: 8, 8
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
^ That's what an atlas pack looks like, so you can assign each image a location and name
The xy: is the location, the size is obviously the size in pixels
i know how atlases work
but
i thought i couldnt implement atlases for this
as it is an atlas itself
arent atlases for combining hundreds of textures into one big one?
It can be, yes
Or, you can take one texture and split it into multiple using the atlas file and loading it as such
In case all of your images are already on one image
but
the file im using as a spritesheet is literally just a png file
I understand
Just treat it as if it's a packed texture
A Texture pack is literally just an image packed with other images, therefore being ONE image
I promise it's that simple
thats what im trying to do
im trying to get standalone textures and store them in a way i can retrieve as such:
SheetAssets[SpriteSheetName]!!["MenuButton"] : TextureRegion
Sprite { File; Region }
Object { Sprite foo; blah ; }
Exactly what a TextureAtlas does.
Try doing this:
Create a TestPack.atlas file with the PNG file in the same folder. Add the png file name to the top of the atlas and a test for the menu button to it like so:
Test.png
size: 647, 558
format: RGBA8888
filter: Nearest, Nearest
repeat: none
Menu Button
rotate: false
xy: 0, 0
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
Load the texture atlas, find the region called "Menu Button", and see how that works?
You now have a texture in your sprite sheet called menu button when you load it up from the PNG file
how do i name the regions?
i guess thats what i tried doing from the beginning
so it supports parsing classical spritesheets
great
If you look at the code I provided, you'll see under the repeat row, that there is a Menu Button text. That's the name of the region, and every time you create a new region, you need to add the tabbed spacing underneath it to provide the rotate, size, offset, etc.
The xy: 0, 0 variable is the location to cut from the image and the size:, 8, 8 is the size in pixels of the image to cut
I assume you're writing this in Kotlin?
ohh
i need to do it manually?
damn
that was the reason why i tried to build a spritesheet parser
textureAtlas.addRegion("name_here"); works
atlas.addRegion(name, texture, x, y, width, height)
If you don't want to use a file
ooh
this is absolutely what im trying to do, thanks
wait
how do i get the texture from it?
i already try to get texture with the parser
TextureRegion(Texture texture, int x, int y, int width, int height)
set the x, y, width, and height of the texture you're taking from
aand we have looped back to the beginning
Texture menuButton = new Texture("TestImage.PNG", 0, 0, 8, 8)
textureAtlas.addRegion("Menu Button", menuButton, 0, 0, 8, 8);
that atlas method is just a method to retrieve the single textures
the problem is automatically assigning it
i think i made an off brand texture atlas already
the problem is that there are 144 textures
How do you mean automatically? Don't you have to assign them a specific name any way? Like "Play Button", "Menu Button", "Exit Button", etc?
i have a linear list for it
if i set it to null it is set to index number
sec ill send an illustration
Dang man. I would really just suggest the atlas regions because it's cleaner and you don't have to write all that code for it
there are 144 textures :/
<.<
so anyone can help?
if u are willing to help please read this:
write a file format that encapsulates the info you want
also id say you're doing it backwards
rather than creating 'regions' in an atlast
everthing you want has a 'sprite' that defines the region of what image
i already have the wrapper or encapsulator
as a mutablemap<string, mutablemap<string, textureregion>>
Yeah wrong direction
ok that is the easy part to fix
but the main problem is that i need to find an algorithm
For?
get specific textures from a png with each texture having width, height, posx, posy variables
with offset in between textures
fun loadSheetAtlas(directoryToSheet: String, names: List<String?>?, width: Int, height: Int, spaceBetweenX: Int, spaceBetweenY: Int, spritesX: Int, spritesY: Int)
```
an example sketch
there is distance between the textures tho
So
Store the regions in a file
that might be what im looking for
does it support distance between textures?
wait
arent sprite font's a bit too "official" and unsuited for game use?
@crimson yacht is this what you want? https://www.codeandweb.com/texturepacker
Bit of an odd request, I'm in need of a sprite font .xnb containing as many unicode characters as possible. I'm building "Arial Unicode MS" right now but its taking a while via the MGCB, wondered if anyone had one already built they could share to save me the few days time it'll take to build 65k glyphs
i already have the sheets
I would build them into multiple sheets probably, or you may just want to find a vector font renderer and bundle an actual font
I have a ttf, It's a little weird of a situation where Im modding an existing MonoGame application and need to load my own SpriteFont to support as much potential user input as possible, without knowing the language theyre gonna use beforehand. I'm currently building the ttf->sprite font->xnb, how would you suggest going about multiple sheets? It's been a while since I've touched MonoGame proper
Right, not a bad shout, I'm using some of the helper functions for displaying text in the original game I'm modding atm so would require writing my own systems for that - which is doable for sure, the code isn't complex. I may go down that route instead - thanks!
but either way i guess
use code pages
they're like 4096 characters a page i think
and one sprite font per code page
then swap em out
Code pages? I'm afraid Im not too familiar with font formats and the like prior to this
its a legacy windows thing
you'd just be emulating/recreating it yourself in code
the spritefont system has support for sparse fonts, but its going to put every character in one sheet I think, which i dont think is what you want
i think i asked the wrong question at the first place
is there a spritesheet parser library or app
im sure someone who built a packer has written one
it will probably just be as quick to write your own
I'm trying libgdx in visual studio code but for some reason it can only compile to desktop. All the other builds say: Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Also, I get some problems:
Could somebody please help me with this?
im trying to make a 2d top-down strategy game with procedurally generated maps but i have no idea how i would implement the tilesystem, which would contain
map
.........chunk
.......................tile
how can i implement it?
the procedurally generated part is the main problem
now i absolutely need to have a list containing activeChunks for like chunks in render distance in minecraft
but i have no base for it
no base code or any tutorial
any help would be appreaciated
procedural generation is a whole topic
this guy has some articles https://www.redblobgames.com/
fun generateMap(seed: Long = 1, Info: Map)
{
var noise = OpenSimplexNoise(seed)
Info.chunks = Array(Info.xChunkLimit) {i -> Array<Chunk>(Info.yChunkLimit) {i -> Chunk()} }
for(x in 0 until Info.xChunkLimit)
for(y in 0 until Info.yChunkLimit)
{
Info.chunks[x][y] = generateChunk(noise, Info,x* xChunkSize, y* yChunkSize).apply { addTileActorsTo(Info) }
//will absolutely cause problems about origin point, row/column misplacement and most importantly negatives
//maybe I should find a way to make TopLeft 0,0 the only point and no one can go beyond it
//but what about the infinite generation?
}
}
fun generateChunk(noise: OpenSimplexNoise, map: Map, ChunkXPos:Int, ChunkYPos:Int) : Chunk
{
var TileList = Array<Array<Tile?>>(xChunkSize) {i-> Array<Tile?>(yChunkSize) {i->null} }
var index = 0
for(x in 0 until xChunkSize ) // those two lines
for(y in 0 until yChunkSize ) // cause problems...
{
var value = noise.eval(x+ChunkXPos.toDouble(), y+ChunkYPos.toDouble())
if(value >= 2)
{
TileList[x][y] = Tile("Plains", value.toFloat(), "Hills")
}
else if(value <= 1 )
{
TileList[x][y] = Tile("Sea", value.toFloat(), "Coast")
}
else
{
TileList[x][y] = Tile("Plains", value.toFloat(), "")
}
}
return Chunk(TileList).apply { addTileActorsTo(map) }
}
fun render()
{
Gdx.gl.glClearColor(1f, 1f, 1f, 1f)
//Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
mainBatch.begin()
var xx = 0f
var yy = 0f
for((index, tile) in tiles.withIndex())
{
if(tile?.texture!=null)
{
xx = nToXY(index, xChunkSize, yChunkSize).x
yy = nToXY(index, xChunkSize, yChunkSize).y
mainBatch.draw(tile.texture, floor(nToXY(index, xChunkSize, yChunkSize).x), floor(nToXY(index, xChunkSize, yChunkSize).y))
}
}
mainBatch.end()
}```
could someone please help?
tiles is null for some reason
`nvm
Anyone know anything about shaders? I don' think I've implemented mine the right way
System.InvalidOperationException: This resource could not be created.
at Microsoft.Xna.Framework.Audio.AudioEngine..ctor(String settingsFile, TimeSpan lookAheadTime, String rendererId)
at Terraria.Audio.LegacyAudioSystem..ctor()
at Terraria.Main.LoadContent()
at Microsoft.Xna.Framework.Game.Initialize()
at Terraria.Main.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
traceback
help
are you playing terraria? If so I would ask in terraria's forums/submit a bug report
<@&133522354419662848>
- sorry
they told me
to come here
to someone who knows about the framework
the community
this is a question only the devs of terraria can answer
my guess is that maybe it cant load a file
it has to do with the audio, it works fine with no devices but when i plug one in
it crashes
yeah i am not really going to be able to help you much without debugging the program
question
say i have a function called fromPixelScalingToGameScaling
where i do a few multiplication and division calculations inside it
say that i'm calling it 1000 times every frame
would it slow down the program by a considerable amount?
or say like i have this function
fun returnSameObject(number: Int) : Int {return number}
how slower is it than directly passing the object?
what language is this? afaik monogame uses C# and libgdx uses Java, this looks like neither
also, profile it
Hey guys can someone advise why methods of derived class can't be called like that? (C#)
(Derived)BaseClassObject.SomeMethodOfDerivedClass();
But at the same time this works
Derived derived = (Derived)BaseClassObject; derived.SomeMethodOfDerivedClass();
You've just got your parens wrong
((Derived)BaseClassObject).DerivedClassMethod();
@silk jay
Ohh, damn, @flat turret , thanks you so much! I used to c++ where (Derived)BaseClassObject.SomeMethodOfDerivedClass(); is correct, and it confused me)) Thanks much once again!
Russian spy thanked Triple Seven
is this channel good for FNA too?
yes
libgdx uses java which is directly compstoble with kotlin
sorry for late answer
oh wrong person
i meant u
interesting, I didn't know libgdx worked with all JVM languages
I guess that makes sense
@daring widget
👍 ok
spent the last few days looking for a C# ECS library and they all either had bad/nonexistent documentation or were Unity-only, so I wrote my own lol
👍
this is a really stupid question but does FNA dev fit here as well
yes
anyone know of a glsl shader support library for FNA?
or does it support it natively?
why not use hlsl?
Figured out what I'm gonna do, I'm gonna create my shaders in glsl, use glslangValidator to convert them to SPIRV, and then use SPIRV-cross to convert the .spv to hlsl
so im trying to replace music in a game, and i was able to create a new xwb file with new tracks to replace the current xwb, and the game loaded up fine, but the new music in the xwb wont play
anyone know what might be the issue?
can you look at the PCM data by chance (in xna)
make sure you actually created it correctly
Anyone wanna be active in my server? That will be appreciated. Thanks!
Managed to set up a Monogame+Nez project on VS code, the next few weeks are going to be interesting! 😄
late to the party but you should check out LeoECS. It is awesome, lightweight and easy to extend
Regarding Monogame, should I be drawing everything from the main class? I managed to represent a chunk of perlin noise in colors, but when I began to detach the project into separate files, I found myself lost on how to handle drawing in general.
So you've got your Draw method, where you have access to your spritebatch
What you can do is you can add a "Draw" method to your other classes and provide them with the spritebatch, which they can draw themselves into
that way you can do something like
_spriteBatch.Start(); // or whatever the API is, can't remember
foreach(MyClass obj in sceneObjects)
{
obj.Draw(_spriteBatch);
}
_spriteBatch.End(); // or equivalent
I believe Nez has a thing to handle this for you?
You add the Nez object to the scene and it draws itself, or something (I've never actually used Nez, however if you want I can DM you the link to the monogame discord where the nez developer is very active)
Yeah, sounds like what I need. I found the discord as well, I'm glad it's so active 😄
microsoft has some good c# getting started tutorials that could help you understand parameters, references and types
Indeed, however I'm porting an existing project from Unity, I'd like to think I already know the basics, just have to get used to the fact that it's a bit more low-level 👍
when you're using unity, you typically only utilize a tiny subset of the c# language. so when you do other things, there's a huge gap to fill
👋
Hey guys, I need some help with tilemap. I find a lot of information on how to load tmx files. but I need to load XML. Could anyone help with it ?
Pretty sure tmx is xml based
Yeah I've read about it
if you are working in c# you should be able to implement your own parser using the XmlReader from System.XML
if you are in java land I am the wrong guy^^
also if you don't want to re-invent the wheel, there definitely are a bunch of oss parsers for tmx that you could modify. There might be something in monogame extended as well
Uff, okay. I just thought it would be easier because we can load the tmx with one command and I thought there is something for the xml. I just don't understand why did the game studio give me a map in the format xlm instead tmx
you might want to check the actual structure of the file. Maybe it's a tmx file with just an xml file extension?
otherwise it might be easier to write a conversion tool that takes their xml and outputs tmx if you already have an importer for that
(or maybe they just sent a wrong export by accident?)
I've just looked at tmx format and looked at this, doesn't look like tmx
did they supply any documentation for their format?
if they just handed you an xml without any description of how it's set up then that's not really useable
tmx is not your average xml though, so it'll take some work to make it usable
i made a library for dealing with it a while back https://github.com/Ragath/TiledLib.Net might need to be updated to handle the latest Tiled features, but it should handle the vast majority of them
Wait people still use that engine?
is there a way to draw a sprite with no texture (just a solid color), and to add the texture later? in monogame
I don't think its possible with the standard sprite batch... writing a shader should be the best way.
Tbh I think the question is kind of strange. What are you trying to achieve?
I don't have textures right now, so I want to use a solid color as a placeholder.
actually, I think I've found a solution.
private Texture2D SolidColorTexture(int sizeX, int sizeY, Color color)
{
Texture2D texture = new Texture2D(GraphicsDevice, sizeX, sizeY);
Color[] data = new Color[sizeX * sizeY];
for (int i = 0; i < data.Length; i++) data[i] = color;
texture.SetData(data);
return texture;
}
Or you could have just loaded a placeholder texture... But what you asked for was something completely different.
This is not what you want to do. You want to create a 1x1 pixel texture in white and only create it once. You use the Draw overload which accepts scale and color to paint and draw it the necessary size. Everything else is wasteful
Dude, wrote a client/server infrastructure, and a cache updating system. Using runescape sprites as well: https://www.youtube.com/watch?v=YLxWQPpaNTU
¯_(ツ)_/¯
Anyone know how to render a tiled map with a perspective camera (3D)?
render with a 3d perspective matrix and/or to a texture?
^ Not my game, just sharing it with peeps. It's a really cool libgdx project
why are my usings broken? there is a red squiggly line under Microsoft.Xna
you always have an error message associated with the squigglies that explain what's wrong
probably haven't run nuget restore
how do I do that?
normally it happens automatically when you build. But if you've turned it off, then right-click the solution and pick restore
its on. I tried to run it manually, but nothing changed
check the output log for errors then
All packages are already installed and there is nothing to restore.
then you're missing packages
My project has the following packages:
MonoGame.Content.Builder.Task
MonoGame.Framework.DesktopGL
MonoGame.Extended.Tiled
and are those the right packages and on the right project?
I believe so. the first two are the default packages, if I am not mistaken
and I am getting errors on ```
Microsoft.Xna.Framework
Microsoft.Xna.Framework.Graphics
Microsoft.Xna.Framework.Input
MonoGame.Extended.Tiled
MonoGame.Extended.Tiled.Renderers
basically all the namespaces I try to use.
you've probably got a mismatch between the target framework and the monogame package then
either way, your build output still tells you whats failing
probably .net6.0 in your case
which does not play nice with monogame yet
can I use an older framework?
yes
how do I do that?
edit the project
yes, but you should switch to vs2022
Last time I checked the MonoGame VS plugin wasn't avaliable for VS 2022. not sure if its necessary tho.
I just looked and my TargetFramework is netcoreapp3.1. not sure if its what its supposed to be.
.
..
...
....
.....
wow the snake drawing mechanic is really good, must hv taken a lot of thinking eh
I think I made the whole game in like 16 hours where like 8 hours of them were learning the physics and making them feel the way I wanted
drawing was probably around an hour or two
oh
I am working with LibGDX. I want to set the background of a Label such that it resizes with the size of the Label. For that I am using an image which has a size lesser than the Label. However, due to resizing, the result is like this - (refer to the second attached image). So I made the image larger than the Label. However, it doesn't resize like that - (refer to the first attached image). any solutions?
Basicall what you need to create is a 9slice. The center piece can then easily be filled with anything else
oh i see, thanks
Above & Beyond thanked Rhast0r
I need webgl shader code to draw image outline.. Any one can help me?
If i google some of these words i get good hits on google
It is better to state the explicit problem you have and what you have tried. People will be mode inclined to help
if you're asking someone to do it for you, that's not gonna happen. If you have a problem with your implementation, someone might be able to tell you what it is
where to start
any links?
tried a google search?
no res found
either you're following the instructions wrong, or you're phrasing the problem wrong. In which case you need to read up on the subject and learn the right terminology
if its the former, read up on shaders in general
@hot hazelu know easy one
Hello guys i want to step in game development and decided to make 2.5d indie games on java language so what path should i follow
Well i am in intermiadiate level of java programming and i want to make games with libgdx so is there any tutorials on how to make games with libgdx
Seee, this results in a completely different question. No need to feed you beginner stuff.
you might want to check out this https://happycoding.io/tutorials/libgdx/
and since there are many parralels you could also check out MonoGame but that one is C#
i started gamedev in the sae situation i followed the libgdx flappy bird tutorial of a guy named brent aureli. he also has another series in which is he shows how to create mario in libgdx. he makes really good tutorials if u ask me
Hey Everyone,
This week's new free music tracks are:
"SPIFF THE SPACEMAN"
"GRUNGY OLD CODE"
You can freely download them here:
https://soundimage.org/sci-fi-11/
If you can, please consider making a small donation on my website to help support my hard work.
Be well and please stay safe.
Anyone using Box2D here?
!dontask
Hello, I am trying to create 2D game. I want player to be able to go behind a tree or in front. What is the best way to achieve that? I tried using several layers with Tiled map editor (Will attach images), but that did not went as planed. Searched google, but not found any useful information.
you need some kind of front to back ordering, likely just the y value of the bottom pixel
Yeah, but libgdx does not have any of that
then you order them yourself... whichever you draw last is on top
make a Draw() call that puts everything into the list, sort by y, then pass that to the actual draw code
^this is specific to the game and also depends on stuff like layers or pivots of sprites
With help of other person I manage to pull that of with tinkering rendering and shaders
what are you trying to tell us?
That I solved my issue
If you have questions and found a solution you should share your solution with others for you aren't the only one who will have that problem
and drop a little thanks for people that put in the effort to answer your specific question which might be easily googleable so you don't have to
ok so i have a weird problem with libgdx. i tried googling it in many different ways but i cant seem to find an answer
ok so i have a sprite. i am rendering it to the center of the camera (camera is at (0,0), so i render the sprite to (0,0)). it gets rendered to the center of the camera. perfect.
however, now i have to do the PPM conversion. i scale down the size of the viewport and my sprite and render it to the center of the camera (0,0). however, this time, the sprite gets rendered elsewhere, even though its coordinates are still (0,0) according to libgdx. below are some images - (first attachment is PPM = 1 ie no PPM conversion yet, second is PPM = 10)
i have no idea why this is happening
if anyone wants i can send the project root folder here so that they can see exactly what is going on
this issue is solved, it was a problem with the sprite's origin and rotation.
apparently you have to call sprite.setOrigin() again after setting the size to make sure the origin stays where you want it to relative to the sprite's position
guys do you make your own tile map system in monogame? or you just use monogame extended
i was trying to make one using for loops running each frame and my rtx was at 50% usage
I made my own
only render what you can see
and if you really want to cut down on CPU usage, render one quad and calculate tiles in a shader
^
I need mobile game
?
what?
U make games??
yes
So dm me
why?
Please
no
what does that mean?
Why it's 2:46 pm
its 2am here
GraphicsDeviceManager (usually called from your game's constructor) has a PreferMultisampling
alternatively you could write an fxaa/similar post process shader
Thanks
How can i use json? I want to make level for example...(monogame)
Like json files
depending on your .net version you have you might have System.Text.Json but more likely you can add Newtonsoft.Json from NuGet
from there its up to you how to map data to a level
How do you do levels?
thats very much up to your game
So there isn't any editor
So its better to use something like json/xml
not sure what you mean
Like you make levels you make them in json right?
you could probably use a tool like Tiled
theres a library called Monogame.Extended that I think has a parser for tiled's tmx files
Ok thanks
how can i fix this error?
The source file '/Documents/MonogameProjects/Project2/Project2/Content/../testing.tsx' does not exist! Documents\MonogameProjects\Project2\Project2\Content\mapTestUwU.tmx 1
Why does this json content reader doesnt work?
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Newtonsoft.Json;
namespace JsonExtension
{
[ContentImporter(".json", DefaultProcessor = "JsonProcessor")]
public class JsonImporter : ContentImporter<Dictionary<string, dynamic>>
{
public override Dictionary<string, dynamic> Import(string filename, ContentImporterContext context)
{
context.Logger.LogMessage("Importing JSON file: {0}", filename);
using (var streamReader = new StreamReader(filename))
{
JsonSerializer serializer = new JsonSerializer();
return (Dictionary<string, dynamic>)serializer.Deserialize(streamReader, typeof(Dictionary<string, dynamic>));
}
}
}
}
namespace JsonExtension
{
[ContentProcessor]
public class JsonProcessor : ContentProcessor<Dictionary<string, dynamic>, Dictionary<string, dynamic>>
{
public override Dictionary<string, dynamic> Process(Dictionary<string, dynamic> input, ContentProcessorContext context)
{
context.Logger.LogMessage("Processing JSON");
return input;
}
}
}
namespace JsonExtension
{
[ContentTypeWriter]
class JsonTypeWriter : ContentTypeWriter<Dictionary<string, dynamic>>
{
protected override void Write(ContentWriter output, Dictionary<string, dynamic> value)
{
output.Write(JsonConvert.SerializeObject(value));
}
public override string GetRuntimeType(TargetPlatform targetPlatform)
{
return typeof(Dictionary<string, dynamic>).AssemblyQualifiedName;
}
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return "JsonExtension.JsonReader";
}
}
}
@bright hazel its not that simple to make a hierarchial writer
and you'd be better off sending the json to a processor that converts it to a game-specific format and use that
no custom reader/writers needed then
ok
so how are you loading json files?
or do i even need to load them
coudnt i just put them in content folder and access them through path
can anyone help me understand matrix?
Guys why
1.Is there blur
2.The sprite disappears
my player code
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace worldHacking
{
class Object
{
private Texture texture;
private float weight;
public Vector2 pos;
private Vector2 velocity;
private float rotation;
private Color color;
private bool applyGravity;
public Object(Texture pTexture, float pWeight, Vector2 startPos, float pRotation, Color pColor, bool pApplyGravity)
{
texture = pTexture;
weight = pWeight;
pos = startPos;
rotation = pRotation;
color = pColor;
applyGravity = pApplyGravity;
}
public void Update(GameTime gameTime)
{
if (applyGravity)
{
velocity.Y = 9.8f * weight * ((float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000);
}
pos += velocity;
Debug.WriteLine(pos);
}
public void Draw()
{
texture.Draw(pos, rotation, color);
}
}
}
you shouldn't, you should be processing your content at build time instead of runtime
that's the whole purpose of the content pipeline
oh ok
meh, i am not a fan of the content pipeline
esp when debugging
debugs the same way as all other build tools
i mean content debugging not build tool debugging