#monogame-and-libgdx-dev
3045 messages · Page 3 of 4
no, this is spam...
<@&133522354419662848>
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
Yea I like that approach, simple and effective
thanks again!
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
wrong in what direction
can u elaborate?
I already explained
Don't make a dictionary of names to regions
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
Use a grid or a bin packing Algo
Then store the regions in a file
there is distance between the textures tho
how do i generate the "regions"
that is the main problem
parse, i meant
Json,csv
Standard file parsing
Look at Sprite font generators and their output
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
diy
dont use the monogame spritefont system
but honestly id find a TTF renderer
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?
Looking for anyone who wants to develop a game in LibGDX
XD
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
devs are not open to questions
and the forums has been dead for a while
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)
Movement :: Monogame
that's what ik lol
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
yea, it seems like it doesn't find the packages
but I don't know why
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
wdym?
whats the "target framework"?
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
the .csproj?
(on VS 2019)
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.
tis not necessary
TargetFramework can be set to "net6.0" i think
it can, but it wont work if you do
since monogame is broken on .net6
.
..
...
....
.....
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
i just googled "shader image outline"
that not work
i can show trillion of such things
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
there's a number of ways to do an outline
they can get pretty complex
@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
hard question with no real answer
what do you know?
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
?
Accept my request
@hot hazel
Plz
I'll invest in ur game
what?
U make games??
yes
So dm me
why?
Please
no
😫 😩
I m poor
But I'll help
I need help also
@hot hazel
what does that mean?
I'll explain but plz accept my request
.....
no
you can discuss it here
Why u r so rude
Okk
I need a noice mobile gaem
Game
👉👈
i don't know what that means
also why?
Noice=nice
Cause
I m
Gud
Guy
so?
anyway i need to sleep
Why it's 2:46 pm
its 2am here
Ohh
Okk
But can u give one
❓❔❓❔❓
@hot hazel tell
how do you guys do anti aliasing
?
monogame
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
Ok
Thanks
And
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
i mean there are editors yes but every game is different
monogame is not an engine
So its better to use something like json/xml
not sure what you mean
Like you make levels you make them in json right?
json is a data format
you could write it by hand but that would suck
Yeah
But what do you use
i wrote my own stuff
what kind of game are you trying to make?
Just having fun. i was wondering how celeste made their levels
*fun
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
and its simply the correct way of doing content loading
and things like hot reloading
hot reload also works the same regardless of if the content came from a source asset or an xnb
how can i redraw only portion
like i have background and i dont want redraw it each frame
just the player
just a simple question should i assign value of my variables in loadcontent or initialize
its quicker to redraw the background every frame instead of doing it on demand
wdym demand
when needed
really?
but why do i have 20% gpu usage when i am just calling draw with one sprite
yes, its simply quicker for a gpu to do lots of the same work instead of having it pick between doing one thing or another
ok
so i dont have to mind the gpu usage?
the gpu is always working towards the target framerate, so you can't trust usage numbers between 0% and 100%
all you know is if you're at 0% its doing nothing and if its at 100% you're reached the limit
ok
also its a game, dont worry about usage 😛 (optimize but dont fret)
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.
- Donald Knuth
Sure
guys i have problems with tiled sharp... it is throwing an error:
System.IO.FileNotFoundException: Could not find file 'C:\Users...\platformer\platformer\bin\Debug\netcoreapp3.1\testing.tsx'.
when i call new TmxMap(path)
now its like this:
System.IO.FileNotFoundException: Could not find file 'C:\Users...\platformer\platformer\bin\Debug\netcoreapp3.1\mapTestUwU.tmx'.
mapTestUwU.tmx this is the maps file name
ok i found that the error occurred in this line:
map = new TmxMap("mapTestUwU.tmx");
i tried even this:
map = new TmxMap("Content/mapTestUwU.tmx");
there's a big difference between premature optimization and adopting good implementation patterns
okay i got why does it happen... i did not save the tsx file
problem is you're using the wrong library for the job. that one can't deal with content
and as such you're forced to ship the source assets manually and do the slow parsing at runtime
and you won't be able to pre-process it in an automated fashion either, so its gonna be all manual
yeah i tried it with extended but it wont work
give this a go: https://github.com/Ragath/TiledLib.Net it's made to integrate nicely with the content pipeline, so you only have to write the processor that transforms it into your game-specific format
lol i tried that too
i will try it again, thanks!
why is my tileset weird
okay i find out that the id is moved by 2
None.
Zero.
And considering F#'s idiotic syntax, you shouldn't really use it, ever.
Alright good to know
If I may ask, what makes the syntax "idiotic"?
non-conventional mainly is my guess
things that are different, mainly for the sake of being different
you guys use any particular frameworks?
monogame
🤝
<@&133522354419662848> ^
!karma @rain compass
!karma @rain compass
@rain compass thanks
!karma @rain compass
name something you love and hate about monogame, for me I love how I could just start coding my game without having to learn any new tools, but I hate how hard it is to find tutorials on how to make custom shaders
monoagme shaders are the same as regular directx shaders
also, you will find a bunch of old xna shader samples on the internet
who?
I use an ecs framework called LeoECS to replace Monogame.Extended.Entities. It provides better performance, entity pooling via a world OM and respects the CPU cache.
Also, I use a GLSL framework/pipeline called GLSLOptimizerSharp, which is very nice to have in your content pipeline for cross platform shader support. Provides a wrapper for shader compiler for content pipeline to use glsl shaders instead of having to go for hlsl or the fx ones.
Respects the cpu cache eh
Sounds like it should perform like unity's ecs (the pattern isn't the speed boost its the cpu cache stack abuse)
Will check it out
Hello, recently I've been learning Monogame, and gamedev in general, and I've been wondering if design patterns are actually used in gamedev, I've seen that many people ignore them and go straight to development, and in case they are useful, which one would you recommend?
Yup, LeoECS is high in the charts for the independent ECS libraries in the way of performance thanks to CPU stack abuse. Its documentation is in Russian. Thankfully, a couple of forks have the docs translated to English pretty good. Here's the main repo: https://github.com/Leopotam/ecs - Sticking it through google translate does the trick.
It needs a little love to chop shop the third party plugins together and remove the compiler flags / debug code in the ifdef blocks, but the edits are simple and its real real fast. Only took about 24 hours to fix it up the last time he updated.
saber7ooth thanked popcron
I probalby should fork it and commit my local code, now that I mention it, because I use it often and have maintained my own through three of his revisions, I will when I am more awake.
I'll mess with a little jekyll installation and get it some docs before I share it here.
design patterns are tools. you use them when you need them
also see https://gameprogrammingpatterns.com/
Hello, I've started a youtube channel for 2D indie developers, C# tutorials (MonoGame) - take a look, leave feedback, thanks 🙂 https://www.youtube.com/c/GameDevQuickie/videos
https://github.com/loopyd/ecs-saber
As promised I return with at least some functional repo, docs are incomplete but I am working through the mass amount of functions locally so soon™️ I will eventually include a monogame sample project so that its use can be demonstrated when I finish documenting everything.
Got the DocsFX site working with GitHub actions so you can now browse library API documentation. I am still working on C1 end of pipeline to release project, I am following github codeQL security recomendations before I hook that up to deploy to releases, though. CodeQL is hooked up to validate PRs, I will put it into releases after I have finished removing security vulnerability from project as some warnings appeared, so please keep it in mind on Security tab. I gutted his whole framework out and basically have refactored all of it to make it engine agnostic and improved performance further by including LINQ and more modern .NET optimizations. My library is 17% faster than his thanks to just unrolling a lot of the loops and untanging a lot of spaghetti in the original. I spent about the last week on automating builds and docs so there will be much more of that fixing up and optimizing / as well as a full testing framework soon.
hello libgdx folks 👋🏻
yeah all 3 of you
So I have a weird problem in LibGDX where sometimes if I stay in a specific x position with my player, some tiles have a gap between them.
probably happens with y position as well
(the black tiles are indeed tiles)
sus
@stuck elk
<@&133522354419662848>
<@&133522354419662848> ^
you have wrong blendstate
I'm making a 3d game with c# monogame and I have a question regarding smooth alpha ribbon trails with forward rendering.
I organize my particles furthest to closest for when I draw them, which works fine for smooth alpha particles but how would you get ribbon trails to have smooth alpha since the ribbon trail is normally long and flat and go through the particles so its hard to tell if its before or after a particle. plus I currently draw 1 whole ribbon trail, I don't draw the ribbon trail in segments. Anyone have any ideas on how others do this?
Currently to fix the problem I dont use ribbon trails with alpha. But would like to use smooth alpha with ribbon trails.
got some pics?
also sounds like maybe you want a depth buffer?
how would you depth buffer a ribbon trail though since its long and curves in on itself sometimes
a depth buffer just tells the rasterizer to not draw if that pixel has a closer depth
i guess thats how defered rendering would handle alpha collision with particles and ribbon trails?
maybe? deferred can't really handle transparency
at least blending
so even defered has to still order particles from furthest to closest?
idk the details
i just know its why games that use deferred have to render the transparency with dithering
ill find a screenshot that uses particles and ribbon trail
i dont think it lets me post pictures here
here is 2 screenshots that use ribbon trails and particles. the particles are organized from furthest to closest so they work perfectly fine. But the ribbon trail is just drawn after all the particles so the ribbon trail cannot use alpha at all
depth buffer i think should work
otherwise u get ugly 0 alpha around the ribbon trail which hides the particles like the pixel shader is forgetting particles are already drawn
i guess you draw the effects based on thier distance so you have a depth buffer for ribbon trail and a depth buffer for particles? and you merge the colour buffer with the 2 depth buffers?
no
read up on depth buffers
well if you mean for alpha
maybe(?)
but not two depth buffers
i know depth buffers are used in defered rendering to tell how far the colour, normal renders are
kinda same thing we doing for this?
a depth buffer tells you only what the z value was the last time that pixel was rasterized to
so if a second draw call produces a z value with greater than the existing, it's not drawn
also called a zbuffer
maybe you're thinking of a gbuffer?
anyway i gtg
alright ty for your help
ill look into depth buffers
@fleet palm here's a demo of the new version of the engine with that sandbox "floatbox" testing scene (used screen-to-gif to capture which caused some mouse artifacts and the yellow 'click' circle)
Hey! that's really awesome!
Hey CobaltHex, sorry I moved the post to #show-off-your-work
why does this not rotate correctly
Hi guys. Someone mentioned this channel for scripts, snippets, extensions, etc. I’m looking for JavaScript cause I’m developing a web game with p5 library. I’m asking cause, in case it doesn’t exist, I want to create some snippets for everyone.
the font there is really small and can you describe the issue you're seeing?
this channel is mainly for q&a, it is not to advertise
What makes you think I was advertising? I'm asking about scripts, snippets and extensions to develop web games with JavaScript and if no one knows of any I will create and share them for anyone to use.
You're advertising your services ( I don't mean selling) anyway this is for monigame and libgdx not webdev, that's #web-dev
i’m currently working on a 2d engine and i tried box2d for physics but it’s way too complicated for platofrmers, any suggestions?
use separating axis theorem
I've seen a lot about collision detection methods and stuff, how to make it better for rotated shapes or make it efficient with spatial hashing etc.
but no one really talks about combining the collision resolution with detection. resolution is the hard part imo lol
yes
i recommend a book on collision detection/resolution
got a good one specifically?
https://www.amazon.com/Real-Time-Collision-Detection-Interactive-Technology/dp/1558607323 is a good book, not sure how much it handles resolution
https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/swept-aabb-collision-detection-and-response-r3084/ is another placce to get started (particularly "swept collision resolution")
forgot to reply to this, thanks for the links!
yo thanks to this channel i might go back to libgdx
Hey, guys, did anyone manage to get omnisharp to work with MonoGame? I have a cleanly installed Windows and can't get it to work. Any tips?
I'm using VSCode*
Can anyone help me figure out HLSL hardware instancing with monogame?
SV_InstanceId ?
shouldn't be any diff than other dx implementations
I don't use the voice chat sorry
ah ok
so far, I think my normals may be screwed up. got nothing but black when trying to draw
can you open it in render doc/PIX?
nope
why not?
renderdoc complains
try PIX
and can you render a single model?
(not instanced)
mostly. If i remove a specific variable from the lighting calculation in my shader, I can see it
looks perfectly
the segment of the shader code in question:
float4 normal = normalize(mul(input.Normal, WorldInverseTranspose));
float lightIntensity = dot(normal, DiffuseLightDirection);
/* lightIntensity causes black coloring. Possible lighting issue or bad normals? */
output.Color = saturate(DiffuseColor * DiffuseIntensity * lightIntensity);
how I am getting my normals:
internal static Vector3 GetNormal(Vector3 VertexA, Vector3 VertexB, Vector3 VertexC)
{
var XY = VertexA - VertexB;
var ZY = VertexC - VertexB;
XY.Normalize();
ZY.Normalize();
return Vector3.Cross(XY, ZY);
}
@hot hazel I found what was wrong: WorldInverseTranspose was not set!
after fixing this, I found that my normals are indeed borked as well, but at least it's showing an attempt here and there
MESALONMESALONMESALON
<@&133522354419662848> ^
question, could this channel be used for suggestions as well? or is it strictly about code issues/questions
im trying to figure out collisions right now. i've got the basic concept down, allowing for walls to stop player movement, but it's hard to implement things such as gravity and floors. whenever the player is colliding with the floor, its horizontal movement is significantly decreased. also, the jump height is always extremely low, no matter how large i set it to. here's a pastebin containing all of the relevant classes/code: https://pastebin.com/jyX0XGDU
im aware that the jumppower is automatically capped to 320, but even so, it seems as though movement covers more distance than jumping (when not colliding with the floor)
not sure if this is too late now
fix to your slow horizontal movement would be to modify this bit
update x first, check bounds and reset x if intersects
and repeat for y
Hello, I've been solo developing a 3D MMORPG using C# with Monogame called Ruin a game inspired by old school MMORPG's like classic WoW,
In just about 7 hours from now, at 7:00 PM AEST, we're diving into a crucial stress test for Ruin. Your presence would mean a lot to us during this phase. If you're available, we warmly invite you to join us and contribute to testing the server.
If your interested I can send you a Steam CD-Key to download Ruin on Steam, we will be meeting on the Ruin discord but its not required to join our Discord.
Thank you in advance for your support!
Ruin's latest update is now live on Steam. Our Stress Test is set to kick off in just 15 minutes. If you require a CD-Key to access Ruin, simply shoot me a message, and I'll be more than happy to provide you with one for downloading.
Hello guys... Can someone help me with tiled?
Maybe give me small idea about on how it works
what about it do you need help with?
there should be tutorials (incl on youtube) on how to use it
Got a nice top down shooter coming out at the beginning of December all written using libGDX framework
hello
Dynamic Weather in Ruin made in C# Monogame, what do you think of this sunset with thunder.
https://www.youtube.com/shorts/t8D3cbajQG4
Does anyone know where can I learn monogame for C# game development
Sprites.
Ui
Animations
Collisions
Physics
Audio
Etc
what guides have you looked at?
collision/physics can get pretty complicated if you want to roll your own, theres libraries to do all of this
There is a guy named code with sphere and challacade . I didn't find anything else
i assume that's on youtube?
Yes
i'd recommend just searching google
Do you mean documentation or what exactly
doesn't seem to be much there
also you will find a good number of ancient tutorials for XNA
those should all generally work (at least if they target xna 4)
But aren't those outdated
I mean monogame had upgrades since then and same goes to C#
K thx
monogame has tried to stay mostly compatible with xna
or at least has happened to stay mostly compatible
idk how much they try at this point
but it was originally a clone of XNA's api
OK. Now I understand. I took a look at the documentation you sent and I believe it is easy to get started with. Thanks
hello guys, I been doing this school project a couple months ago but I am stuck. When I place a troop it is added to an arraylist, then I iterate through it and then I render and depending the type of troop it is I do certain update method:
if (troop != null) {
if (troop instanceof Slime) {
troop.update(fVp,troopArr);
}
else if (troop instanceof Boulder) {
troop.update(fVp,slime, troopArr, tempArr);
}
troop.render();
}
}```
the thing is that only the boulder is being kind of properly updated (the update method is the one who manages the hitbox) but only the last slime has hitbox, can anyone help me?
feel free to ask for more code
Ive downloaded java over and over again but libgdx keeps saying "Java is not installed"
did you download the jdk or the jre?
^
jre
you need the jdk
oh
jdk 21 right?
¯_(ツ)_/¯
probably is fine
downloaded it
unziped it and the libgdx still wont detect it ;-;
you need to get the installer version
or install whatevers in that zip file
that will update your PATH environment variable, which presumably libGDX uses
oh im using the wrong site
i did the installer and it still wouldnt detect it , i even put both of their folders in the same folder
you could try restarting your machine, though do you have any logs available?
(I don't use libGDX fwiw so I can't be of specific help)
Didn't work either ;-;
im going to explode
can someone help me out, I'm trying to set collision data in tiled map editor and load it using box2d but I'm getting weird results.
relevant code :
MapLayer collisionLayer = tmap.getLayers().get("Collisions");
for(RectangleMapObject rectangleMapObject : collisionLayer.getObjects().getByType(RectangleMapObject.class)){
Rectangle rectangle = rectangleMapObject.getRectangle();
BodyDef bDef = new BodyDef();
bDef.position.set(new Vector2(rectangle.x, rectangle.y));
bDef.type = BodyType.StaticBody;
Body body = world.createBody(bDef);
PolygonShape shape = new PolygonShape();
shape.setAsBox(rectangle.width, rectangle.height);
body.createFixture(shape, 0.0f);
shape.dispose();
}
same level in tiled editor
SetAsBox takes half sizes looks like
so you need something like var hw = rectangle.width / 2; var hh = rectangle.height / 2; position.set(new Vector2(rectangle.x + hw, rectangle.y + hh)); ..setAsBox(hw, hh);
^
thank you
stoozee thanked cobalthex
I thought position started on the topleft and not the center
mb
Do you have a game Idea or a reference you’ll like to bring to reality?
I’m available to work with you for your game developments
Coming from godot
Easy entry?
?
to monogame?
if yes, monogame is not an engine so you will be doing a lot more work by yourself
yes it is easy
does anyone know to how make sprite rotate around another sprite in monogame
i am trying to remake pop the lock game
as in orbit another sprite?
var currentOrbitAngleRadians = MathHelper.PiOver2;
var orbitPosition = centerPosition + new Vector2(
MathF.Cos(currentOrbitAngleRadians) * orbitRadius,
MathF.Sin(currentOrbitAngleRadians) * orbitRadius);```
how do i make it move
animate currentOrbitAngleRadians
i am beginner so i dont understand
the sprite has position and rotation
currentOrbitAngleRadians += (gameTime.ElapsedGameTime * someSpeed) % MathHelper.TwoPi;
what is te current orbit angle connected to
is it x postion or y position
neither
it is an angle
then how does it move
orbitPosition would be your sprite's position
k
centerPosition is what you want to orbit around
k now i understand
not moving
float orbitRadius = 135f;
float currentOrbitAngleRadians = MathHelper.PiOver2;
Vector2 orbitPosition = Centre + new Vector2(
MathF.Cos(currentOrbitAngleRadians) * orbitRadius,
MathF.Sin(currentOrbitAngleRadians) * orbitRadius);
currentOrbitAngleRadians += speed % MathHelper.TwoPi;
this is the code
you have to save currentOrbitAngleRadius somewhere where it won't be reset every frame
ok i solved
what about rotation
do you know how can i do it
it is a cylinder
if you're going clockwise, angle is currentOrbitRadiusAngle is + 90deg, if you're going counter clockwise is -90
90 deg = MathHelper.PiOver2
I recommend studying up on some trigonometry for this
ok
thanks
do you know any equation for it
equation?
or how to do this
or what exactly should i search for to get an answer
i just told you
so i convert currenOrbitRadians to angle then add 90
and if anti clockwise i subtract 90
?
ok thanks it works now
So I am currently trying to enhance my abilities in monogame so I am planning to make a 2d shooter game where the player is in middle of screen and you rotate him and shoot enemies that spawn randomly and move toward player . I plan to try implementing UI and a Particle system so is it better to just watch a tutorial for them first or try experimenting first and figure it out then watch a tutorial as a refinement . Any thoughts?
Experiment
You'll learn a lot more
OK thanks
Texture2D.FromStream/FromFile
Monogame.Extended has a shapes library IIRC
xna is a wrapper around directx, directx doesn't do shapes, its up to you to implement that.
Two of the ways you can do it:
- Create a 1x1 white pixel texture (new Texture2D() then texture.SetData() ), stretch that to whatever size you want
- Draw primitives and use a shader to fill in the color (you probably will want a custom shader here)
it can go in any folder you want
visual studio can be a bit weird with the working directory, but when running an app, by default, the working directory is the location the exe is in
so if you say FromFile("foo/bar")
foo is relative to that working directory
^
I'm gonna ask for libgdx help here
Oh wait monogame is an engine :(
I was going to try and make an engine in mono game
got this far
experiencing a horible bug
dont ask just to ask, ask
not an error, a bug
Im trying to get it were wasd is local space
and not worldspace
the video is in world space were w is on the world grid instead of where im looking
Yep, I was trying to tell you here 😅 #gamedev-chat message
You have to construct a new vector from the camera rotation to get the 'forward' direction
And then scale it based on your W/S movement
so I have to quit and do everything in opengl
You don't have to
Using MonoGame is still 100% fine
but its a game engine
Is that a problem?
yes
monogame is a framework not an engine
ok now im even more confused
thats what I said originaly
but both he and this said it was an engine
well that's just 'somewhere to put it'
I would have put it under other dev
¯_(ツ)_/¯
Why is it a problem?
It's open source, pretty mature and has a decent community
because you cant make an engine in an engine
you arguably could, though it would be silly
but yes monogame is a framework not an engine, perfectly suitable for diy
well I might be switching to silk.net or the C# version of opengl (I forgot the name)
I was right hehe
got it working
finaly
I really gota find a way to have the models work with out me join all the pieces
what do you mean join all the pieces?
as in not having to combine the meshes into one?
yeah
whats causing you trouble?
ok, what are you trying? I understand they're all rendering on top of each other
trying to make it look exactly how it is in blender
i need more technical detail...
typically for transforms you either use matrices or something like qual quaternions
what more can I give
what hav you tried?
where are you getting stuck?
are you looking for help?
yes
a lot but nothing specific
well as I mentioned above, typically you use recursive transforms via matrices or dual quaternions
if you have Root > A > B > C > Leaf
Root has the world transforms, A = root * A's local transforms, B = A * B's local transforms, etc
(maybe reverse order for multiplication)
?
My first game in its infancy
It took me WEEKS to get block rendering to work. Resorting to ChatGPT was my only option lmao I hate the tutorials for LibGDX
For those who want to see a scope for the game, I'm going for a sort of Terraria clone (Big But Principle incoming) BUT, it's top-down like the OG Zelda, and there are sort of "levels" (caves, underwater, etc.) to a procedurally generated world. Here's my TODO list:
Anybody experienced with 3D Engines in XNA? Got a Voxel Engine generating trees, however, it only generates the leafs and not the trunk for some reason.
The code, I've tried adjusting the trunk height and a bunch of other options, but can't seem to figure out what's going on
do you have any debug drawing capabilities?
Hmh good one, unfortunately no. I'm not that experienced just yet but will look into that.
i recommend adding stuff like that where you can draw debug lines/shapes in-scene
Will do that 😉 Thanks for the suggestion
my end goal is to end up having my game look something akin to this, but I have no real experience dealing with graphic code. Can this look be achieved purely through HLSL?
I know MonoGame has the Effect class, and the Basic Effect seems to do some nice stuff. But I dont know if an Effect of an FX file is the right way to go about making a look like this
can someone please tell me what's wrong with the load method in player
it keeps giving me that _animPlayer is null
your load method is static
likely an order of operations issue
esp since you're creating a new anim player for every instance
yea cuz I’m using it in another program
Is it not supposed to be
that is for you to decide, but it doesn't really make sense how you're doing it now
How would u normally do it
either pass in the anim player, or move it into the consturctor
god damn i was so dumb
ty i finally know the hell i was doing
What's this channel for
it's in the name
What's Monogame and Lib GDX?
game libraries
They're simpler than engines but provide some os abstraction to make it easier to get up and running
The helpful part is you're not stuck with the systems that they put in
You can also access a lower level system whenever you want
So you can mold it yourself if necessary
Let's collaborate. It's easy for me to fix game issues, and also I found it super convenient to develop a new game
<@&133522354419662848> is this allowed or nah ther3s alot of it in this server tbh
Hello
hi
Happy New Year!!!!!!!!
<@&133522354419662848>
Hi
hi felix!!
what do you mean using another medium?
alright peeps: I'm lacking a bit of common sense I guess, but I was fairly sure this code would work. I'm missing a calculation, could someone point me to what I'm missing:
Vector2 origin = new Vector2(x, y).add(weapon.bulletOrigin).rotateDeg(rotation);
Vector2 target = new Vector2(worldMouseX, worldMouseY);
What are you trying to do?
Well it's fixed now but I just wanted the bullets to be shot from the top of the weapon as I rotated. I just wanted taking into account the origin of the player
Does anyone have a good way to familiarize me with LibGDX please?
practice, read existing code
After i exit my Game there is a white screen and it seems like Lib.gdx is closing but the App is still active. I use first Gdx.app.exit(); and after that System.exit(0). Someone have a solution for this?
Found a way, just had a wrong Interface for System.exit(0)
hello
hello
so were not gonna talk ab how this person has a cursor on his phone?
plug in a mouse
Could also just be an emulator
hello
Hi
<@&133522354419662848>
monogame love and support
<@&133522354419662848>
How can I work with custom devanagari fonts? Tried with the normal spritefont method but the complex conjuncts seem to be broken and it doesnot look good.
for monogame? You will likely need to write your own spritefonts or modify the monogame one to support the character ranges you need
Yep, had to do that. Did it with the help of HarfBuzzSharp and SkiaSharp and it worked!
Hey does anyone have experience with libgdx? Would you recommend for a small game
sure
Monogame engine library and project using that library commits so far
Converting a .bat file game to monogame. Time to rewrite 14755 lines
That's a job for AI.
oh?
hello
Hi, How are you?
After trial and tribulation of having to swap how my renderer handles ui calls, I now have some nice ui loaded in from json!
Testing out resource ui feedback, big fan of this but def need to add a setting to disable it lol
flickering was from layerDepth being too similar
Added grass particles when spawning the grassy wassy and changed color of point trails
https://imgur.com/vAWd1BA
rewriting my silly tetris clone from the ground up
one day I will work on real projects
cool new effects (again)
kool kounterz
sounds
Anyone use skeletal 2d animations? I've realized there doesn't seem to be basically any tutorial or actual way to do this within the past 5+ years lol
hasn't really changed 😛
it's not any different from 3d skeleton stuff fwiw
If you're going to go through the effort of rigging a 2d sprite for animation, you might as well learn full 3d rigging and animation. You get the added simplicity of any angle. https://github.com/chrishayesmu/Blender-Spritesheet-Renderer
that's pre-rendered animation, not the same thing as in-game skeletal animation
Right. Another thing worth mentioning is that Spine is proprietary software with a relatively constrictive license. You can only use it on 1 computer at a time and costs $369 per year for the "full" product. If a developer is just starting out, it is worth it to consider low poly blender animations, especially if their game is not a left-to-right platformer.
<@&133522354419662848>
Hello libgdx developers 🙂
What do u guys think about this kind of games ?
Not much depth to this kind of game. I prefer asteroid-like controls where you can move in any direction.
Random zigzag up a mountain. Width of the passage varies too. Padding on the left and right.
You mean this style ?
Like this. This game even has split screen multiplayer! Absolutely amazing game.
"fully" working menu, oml took a while
🚀✨ If you’re into a charming, fast-paced space shooter, take a look at my game — cute sprites, polished visuals, and just the right amount of challenge. It might be exactly the kind of adventure you love playing! 💫🎮
How to learn libGDX?
tutorials and reference guides?
is there any better way to have fonts in lib gdx than the bit map ones? Bitmap fonts are practically obsolete for ttf files and the always show up blurry unless i used a large image size
I can't speak specifically to libGDX, but rendering vector fonts is expensive, so even if games use them, they often get pre-rendered to character atlases on startup/demand
Yes
👋
👋