#monogame-and-libgdx-dev

3045 messages · Page 3 of 4

frigid fiber

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)

hot hazel

no, this is spam...

<@&133522354419662848>

slate echo

The first step is removing all Microsoft.Xna.Framework.XXX references and replacing them with references to MonoGame.Framework and MonoGame.Framework.Content.Pipeline. This is required as you will no longer be building against Microsoft XNA.

I'm getting a lot of build errors

flat turret

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

dusty drum

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

hot hazel

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)

frigid dagger

@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

dusty drum

ah great thank you so much @frigid dagger

weak salmonBOT

talis thanked Melt

dusty drum

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

flat turret

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

frigid dagger

@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

dusty drum

are you manually creating that xml?

frigid dagger

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

dusty drum

ah okay, makes sense

frigid dagger

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

dusty drum

Yea I like that approach, simple and effective

thanks again!

frigid dagger

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

dusty drum

ah that's a good idea, yea ill have to build a little editor at some point

frigid dagger

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 🙂

velvet stratus

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 ...

flat turret

with mgcb? Those should be precompiled once in the mgcb editor (or just toss that out and spin up your own asset loader)

grizzled forge

hi

stop trying to shag my dad he doesnt want you

ye

he is a good man

he doesnmt want you

hot hazel

@grizzled forge are you ok?

lone patio

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

hot hazel

Edit the project files and see, I don't use mgcb but everything was always project relative for xna

honest fjord

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://javacakegames.itch.io/zero-gravity

silk oracle
silk oracle
silk oracle

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

crimson yacht

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

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

crimson yacht

like the algortihm of it

crimson yacht

help

silk oracle

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

@crimson yacht

crimson yacht
silk oracle

so, you're wanting to assign each texture a specific location you can pull from?

because some have different padding between?

crimson yacht
silk oracle

So, you have a sprite sheet with images that all have different lengths between them, right?

crimson yacht

something like this

silk oracle

Looks like all of those GUI elements have more than a padding of 0

are you using LibGDX?

crimson yacht

yes

crimson yacht

but still, a good candidate for applying padding

silk oracle
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

crimson yacht

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?

silk oracle

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

crimson yacht

the file im using as a spritesheet is literally just a png file

silk oracle

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

crimson yacht

im trying to get standalone textures and store them in a way i can retrieve as such:

SheetAssets[SpriteSheetName]!!["MenuButton"] : TextureRegion

hot hazel

Sprite { File; Region }
Object { Sprite foo; blah ; }

silk oracle

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

crimson yacht

i guess thats what i tried doing from the beginning

so it supports parsing classical spritesheets

great

silk oracle

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?

crimson yacht

ohh

i need to do it manually?

damn

that was the reason why i tried to build a spritesheet parser

silk oracle

textureAtlas.addRegion("name_here"); works

atlas.addRegion(name, texture, x, y, width, height)

If you don't want to use a file

crimson yacht

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

silk oracle

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

crimson yacht

aand we have looped back to the beginning

silk oracle

Texture menuButton = new Texture("TestImage.PNG", 0, 0, 8, 8)

textureAtlas.addRegion("Menu Button", menuButton, 0, 0, 8, 8);

crimson yacht

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

crimson yacht
silk oracle

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?

crimson yacht

if i set it to null it is set to index number

sec ill send an illustration

silk oracle

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

crimson yacht

there are 144 textures :/

silk oracle

<.<

crimson yacht

so anyone can help?

crimson yacht
hot hazel

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

crimson yacht

as a mutablemap<string, mutablemap<string, textureregion>>

crimson yacht

@hot hazel ?

hot hazel

Yeah wrong direction

crimson yacht

wrong in what direction

can u elaborate?

hot hazel

I already explained

Don't make a dictionary of names to regions

crimson yacht

ok that is the easy part to fix

but the main problem is that i need to find an algorithm

hot hazel

For?

crimson yacht

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

hot hazel

Use a grid or a bin packing Algo

Then store the regions in a file

crimson yacht
hot hazel

Store the regions in a file

crimson yacht

how do i generate the "regions"

that is the main problem

parse, i meant

hot hazel

Json,csv

Standard file parsing

Look at Sprite font generators and their output

crimson yacht

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?

hot hazel
final kestrel

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

hot hazel
final kestrel
hot hazel I would build them into multiple sheets probably, or you may just want to find a...

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

hot hazel

diy

dont use the monogame spritefont system

but honestly id find a TTF renderer

final kestrel

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!

hot hazel

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

final kestrel

Code pages? I'm afraid Im not too familiar with font formats and the like prior to this

hot hazel

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

crimson yacht

i think i asked the wrong question at the first place

is there a spritesheet parser library or app

hot hazel

im sure someone who built a packer has written one

it will probably just be as quick to write your own

raw warren

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?

silk oracle

Looking for anyone who wants to develop a game in LibGDX

XD

crimson yacht

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

hot hazel

procedural generation is a whole topic

crimson yacht
        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

crimson yacht

`nvm

lone radish

Anyone know anything about shaders? I don' think I've implemented mine the right way

hot hazel

or

!dontask

weak salmonBOT
raw warren

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

hot hazel

<@&133522354419662848>

  • sorry
raw warren

to come here

to someone who knows about the framework

the community

hot hazel

this is a question only the devs of terraria can answer

raw warren

devs are not open to questions

and the forums has been dead for a while

hot hazel

my guess is that maybe it cant load a file

raw warren

it has to do with the audio, it works fine with no devices but when i plug one in

it crashes

hot hazel

yeah i am not really going to be able to help you much without debugging the program

crimson yacht

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?

flat turret

what language is this? afaik monogame uses C# and libgdx uses Java, this looks like neither

hot hazel

also, profile it

silk jay

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();

flat turret

You've just got your parens wrong

((Derived)BaseClassObject).DerivedClassMethod();

@silk jay

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!

weak salmonBOT

Russian spy thanked Triple Seven

fathom scarab

is this channel good for FNA too?

hot hazel

yes

crimson yacht

sorry for late answer

oh wrong person

flat turret

interesting, I didn't know libgdx worked with all JVM languages

I guess that makes sense

lost terrace

@daring widget

hot hazel

👍 ok

tepid rock

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

hot hazel

👍

tepid rock

this is a really stupid question but does FNA dev fit here as well

hot hazel

yes

tepid rock

anyone know of a glsl shader support library for FNA?

or does it support it natively?

hot hazel

why not use hlsl?

tepid rock

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

flint temple

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?

hot hazel

make sure you actually created it correctly

raw warren

Anyone wanna be active in my server? That will be appreciated. Thanks!

hot hazel
turbid grove

Managed to set up a Monogame+Nez project on VS code, the next few weeks are going to be interesting! 😄

toxic wigeon
turbid grove

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.

flat turret

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)

raw warren

Movement :: Monogame

that's what ik lol

turbid grove
quiet ibex
turbid grove
quiet ibex

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

pine gate

👋

mortal tendon

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 ?

digital dragon

Pretty sure tmx is xml based

mortal tendon
digital dragon

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

mortal tendon

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

digital dragon

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?)

mortal tendon

I've just looked at tmx format and looked at this, doesn't look like tmx

digital dragon

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

quiet ibex

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

sonic basin

Wait people still use that engine?

grave fable

is there a way to draw a sprite with no texture (just a solid color), and to add the texture later? in monogame

lament gyro

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?

grave fable

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;
        }
lament gyro

Or you could have just loaded a placeholder texture... But what you asked for was something completely different.

toxic wigeon
silk oracle
toxic wigeon

¯_(ツ)_/¯

silk oracle

Anyone know how to render a tiled map with a perspective camera (3D)?

hot hazel
silk oracle
grave fable

why are my usings broken? there is a red squiggly line under Microsoft.Xna

quiet ibex
grave fable

yea, it seems like it doesn't find the packages

but I don't know why

quiet ibex

probably haven't run nuget restore

grave fable

how do I do that?

quiet ibex

normally it happens automatically when you build. But if you've turned it off, then right-click the solution and pick restore

grave fable

its on. I tried to run it manually, but nothing changed

quiet ibex

check the output log for errors then

grave fable

All packages are already installed and there is nothing to restore.

quiet ibex

then you're missing packages

grave fable

My project has the following packages:

MonoGame.Content.Builder.Task
MonoGame.Framework.DesktopGL
MonoGame.Extended.Tiled
quiet ibex

and are those the right packages and on the right project?

grave fable

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.

quiet ibex

you've probably got a mismatch between the target framework and the monogame package then

grave fable

wdym?

whats the "target framework"?

quiet ibex

either way, your build output still tells you whats failing

probably .net6.0 in your case

which does not play nice with monogame yet

grave fable

can I use an older framework?

quiet ibex

yes

grave fable

how do I do that?

quiet ibex

edit the project

grave fable

the .csproj?

(on VS 2019)

quiet ibex

yes, but you should switch to vs2022

grave fable

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.

hot hazel

tis not necessary

TargetFramework can be set to "net6.0" i think

quiet ibex

it can, but it wont work if you do

since monogame is broken on .net6

knotty cedar

.

hoary basin

..

toxic wigeon

...

hoary basin

....

worldly jetty

.....

toxic wigeon

I had a couple of hours to kill and made a small game

final herald
toxic wigeon

drawing was probably around an hour or two

final herald

oh

final herald

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?

toxic wigeon

Basicall what you need to create is a 9slice. The center piece can then easily be filled with anything else

weak salmonBOT

Above & Beyond thanked Rhast0r

rain compass

I need webgl shader code to draw image outline.. Any one can help me?

toxic wigeon

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

quiet ibex
quiet ibex

tried a google search?

rain compass

no res found

quiet ibex

i just googled "shader image outline"

rain compass

that not work

i can show trillion of such things

quiet ibex

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 hazel

there's a number of ways to do an outline

they can get pretty complex

rain compass

@hot hazelu know easy one

nimble rose

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

toxic wigeon

hard question with no real answer

what do you know?

nimble rose

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

toxic wigeon

Seee, this results in a completely different question. No need to feed you beginner stuff.

and since there are many parralels you could also check out MonoGame but that one is C#

final herald
radiant sail

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.

upbeat osprey

Anyone using Box2D here?

hot hazel

!dontask

weak salmonBOT
placid gate

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.

hot hazel

you need some kind of front to back ordering, likely just the y value of the bottom pixel

placid gate

Yeah, but libgdx does not have any of that

toxic wigeon

then you order them yourself... whichever you draw last is on top

hot hazel

make a Draw() call that puts everything into the list, sort by y, then pass that to the actual draw code

toxic wigeon

^this is specific to the game and also depends on stuff like layers or pivots of sprites

placid gate

With help of other person I manage to pull that of with tinkering rendering and shaders

toxic wigeon
placid gate

That I solved my issue

toxic wigeon

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

final herald

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

final herald
bright hazel

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

hot hazel

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

flat meteor

I need mobile game

hot hazel

?

flat meteor

Accept my request

@hot hazel

Plz

I'll invest in ur game

hot hazel

what?

flat meteor

U make games??

hot hazel

yes

flat meteor

So dm me

hot hazel

why?

flat meteor

Please

hot hazel

no

flat meteor

😫 😩

I m poor

But I'll help

I need help also

@hot hazel

hot hazel

what does that mean?

flat meteor

I'll explain but plz accept my request

.....

hot hazel

no

you can discuss it here

flat meteor

Why u r so rude

Okk

I need a noice mobile gaem

Game

👉👈

hot hazel

i don't know what that means

also why?

flat meteor

Noice=nice

Cause

I m

Gud

Guy

hot hazel

so?

anyway i need to sleep

flat meteor

Why it's 2:46 pm

hot hazel

its 2am here

flat meteor

Ohh

Okk

But can u give one

❓❔❓❔❓

@hot hazel tell

bright hazel

how do you guys do anti aliasing

?

monogame

hot hazel

alternatively you could write an fxaa/similar post process shader

bright hazel

Thanks

How can i use json? I want to make level for example...(monogame)

Like json files

hot hazel

depending on your .net version you have you might have System.Text.Json but more likely you can add Newtonsoft.Json from NuGet

bright hazel

Ok

Thanks

And

hot hazel

from there its up to you how to map data to a level

bright hazel

How do you do levels?

hot hazel

thats very much up to your game

bright hazel

So there isn't any editor

hot hazel

i mean there are editors yes but every game is different

monogame is not an engine

bright hazel

So its better to use something like json/xml

hot hazel

not sure what you mean

bright hazel

Like you make levels you make them in json right?

hot hazel

json is a data format

you could write it by hand but that would suck

bright hazel

Yeah

But what do you use

hot hazel

i wrote my own stuff

what kind of game are you trying to make?

bright hazel

Just having fun. i was wondering how celeste made their levels

*fun

hot hazel

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

bright hazel

Ok thanks

bright hazel

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

bright hazel

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";
        }
    }
}
quiet ibex

@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

bright hazel

ok

bright hazel

so how are you loading json files?

bright hazel

or do i even need to load them

coudnt i just put them in content folder and access them through path

bright hazel

can anyone help me understand matrix?

bright hazel

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);
        }
        
       
    }
}
quiet ibex

that's the whole purpose of the content pipeline

bright hazel

oh ok

hot hazel

esp when debugging

quiet ibex

debugs the same way as all other build tools

hot hazel

i mean content debugging not build tool debugging

quiet ibex

and its simply the correct way of doing content loading

hot hazel

and things like hot reloading

quiet ibex

hot reload also works the same regardless of if the content came from a source asset or an xnb

bright hazel

how can i redraw only portion

like i have background and i dont want redraw it each frame

just the player

bright hazel

just a simple question should i assign value of my variables in loadcontent or initialize

quiet ibex
bright hazel

wdym demand

quiet ibex

when needed

bright hazel

really?

but why do i have 20% gpu usage when i am just calling draw with one sprite

quiet ibex

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

bright hazel

ok

so i dont have to mind the gpu usage?

quiet ibex

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

bright hazel

ok

hot hazel

also its a game, dont worry about usage 😛 (optimize but dont fret)

limber matrix

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
hot hazel

Sure

bright hazel

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)

bright hazel

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");

quiet ibex
bright hazel
quiet ibex

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

bright hazel
quiet ibex
bright hazel

lol i tried that too

i will try it again, thanks!

bright hazel

why is my tileset weird

okay i find out that the id is moved by 2

earnest yew

None.

Zero.

And considering F#'s idiotic syntax, you shouldn't really use it, ever.

swift crater

Alright good to know

If I may ask, what makes the syntax "idiotic"?

hot hazel

things that are different, mainly for the sake of being different

signal birch

you guys use any particular frameworks?

hot hazel

monogame

signal birch

🤝

hot hazel

<@&133522354419662848> ^

rain compass

!karma @rain compass

weak salmonBOT
rain compass

!karma @rain compass

weak salmonBOT
rain compass

@rain compass thanks

!karma @rain compass

weak salmonBOT
stoic flax

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

hot hazel

also, you will find a bunch of old xna shader samples on the internet

tender relic

who?

scarlet plaza

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.

signal birch

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

rough knoll

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?

scarlet plaza
signal birch Sounds like it should perform like unity's ecs (the pattern isn't the speed boos...

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.

weak salmonBOT

saber7ooth thanked popcron

scarlet plaza

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.

scarlet plaza

I'll mess with a little jekyll installation and get it some docs before I share it here.

flat turret
proven briar
scarlet plaza

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.

scarlet plaza

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.

shrewd kraken

hello libgdx folks 👋🏻

vernal oar

yeah all 3 of you

fossil sparrow

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)

modest cradle

sus

hot hazel

@stuck elk

raw warren

<@&133522354419662848>

hot hazel

<@&133522354419662848> ^

quiet ibex

you have wrong blendstate

woven shoal

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.

hot hazel

also sounds like maybe you want a depth buffer?

woven shoal

how would you depth buffer a ribbon trail though since its long and curves in on itself sometimes

hot hazel

a depth buffer just tells the rasterizer to not draw if that pixel has a closer depth

woven shoal

i guess thats how defered rendering would handle alpha collision with particles and ribbon trails?

hot hazel

maybe? deferred can't really handle transparency

at least blending

woven shoal

so even defered has to still order particles from furthest to closest?

hot hazel

idk the details

i just know its why games that use deferred have to render the transparency with dithering

woven shoal

ill find a screenshot that uses particles and ribbon trail

i dont think it lets me post pictures here

hot hazel

fwiw the dithering will work too just won't have blended alpha is all

woven shoal

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

hot hazel

depth buffer i think should work

woven shoal

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?

hot hazel

no

read up on depth buffers

well if you mean for alpha

maybe(?)

but not two depth buffers

woven shoal

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?

hot hazel

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

woven shoal

alright ty for your help

ill look into depth buffers

stoic flax

@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)

hot hazel
woven shoal
bright hazel

why does this not rotate correctly

viscid cedar

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.

hot hazel
hot hazel
viscid cedar
hot hazel

You're advertising your services ( I don't mean selling) anyway this is for monigame and libgdx not webdev, that's #web-dev

vernal nymph

i’m currently working on a 2d engine and i tried box2d for physics but it’s way too complicated for platofrmers, any suggestions?

sturdy prairie

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

hot hazel

i recommend a book on collision detection/resolution

sturdy prairie

got a good one specifically?

hot hazel
sturdy prairie

forgot to reply to this, thanks for the links!

raw warren

yo thanks to this channel i might go back to libgdx

still egret

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*

hoary surge

Can anyone help me figure out HLSL hardware instancing with monogame?

hot hazel

shouldn't be any diff than other dx implementations

hoary surge

@hot hazel wanna join me in VC?

hot hazel

I don't use the voice chat sorry

hoary surge

ah ok

so far, I think my normals may be screwed up. got nothing but black when trying to draw

hot hazel

can you open it in render doc/PIX?

hoary surge

nope

hot hazel

why not?

hoary surge

renderdoc complains

hot hazel

try PIX

and can you render a single model?

(not instanced)

hoary surge

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);
    }
hoary surge
ashen sleet

MESALONMESALONMESALON

hot hazel

<@&133522354419662848> ^

worldly cobalt

question, could this channel be used for suggestions as well? or is it strictly about code issues/questions

calm bough

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)

mighty herald

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

woven shoal

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!

woven shoal

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.

hot hazel
raw warren

Hello guys... Can someone help me with tiled?

Maybe give me small idea about on how it works

hot hazel

there should be tutorials (incl on youtube) on how to use it

silk oracle

Got a nice top down shooter coming out at the beginning of December all written using libGDX framework

vagrant sluice

hello

slender island
woven shoal
raw warren

Does anyone know where can I learn monogame for C# game development

Sprites.
Ui
Animations
Collisions
Physics
Audio
Etc

hot hazel

collision/physics can get pretty complicated if you want to roll your own, theres libraries to do all of this

raw warren
hot hazel

i assume that's on youtube?

raw warren

Yes

hot hazel

i'd recommend just searching google

raw warren

Do you mean documentation or what exactly

hot hazel

documentation, tutorials

raw warren

What about this

hot hazel

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)

raw warren

But aren't those outdated

I mean monogame had upgrades since then and same goes to C#

K thx

hot hazel

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

raw warren

OK. Now I understand. I took a look at the documentation you sent and I believe it is easy to get started with. Thanks

raw warren

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

glacial chasm

Ive downloaded java over and over again but libgdx keeps saying "Java is not installed"

hot hazel

did you download the jdk or the jre?

glacial chasm

jre

hot hazel

you need the jdk

glacial chasm

oh

glacial chasm
hot hazel

¯_(ツ)_/¯

probably is fine

glacial chasm

downloaded it

glacial chasm
hot hazel

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

glacial chasm

oh im using the wrong site

glacial chasm
hot hazel

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)

glacial chasm

Didn't work either ;-;

im going to explode

wispy sorrel

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

hot hazel

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);

wispy sorrel
weak salmonBOT

stoozee thanked cobalthex

wispy sorrel

I thought position started on the topleft and not the center

mb

stark forum

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

raw warren

Coming from godot

Easy entry?

hot hazel

?

to monogame?

if yes, monogame is not an engine so you will be doing a lot more work by yourself

wild oracle

yes it is easy

raw warren

does anyone know to how make sprite rotate around another sprite in monogame

i am trying to remake pop the lock game

hot hazel

as in orbit another sprite?

var currentOrbitAngleRadians = MathHelper.PiOver2;
var orbitPosition = centerPosition + new Vector2(
  MathF.Cos(currentOrbitAngleRadians) * orbitRadius,
  MathF.Sin(currentOrbitAngleRadians) * orbitRadius);```
raw warren
hot hazel

animate currentOrbitAngleRadians

raw warren

i am beginner so i dont understand

the sprite has position and rotation

hot hazel

currentOrbitAngleRadians += (gameTime.ElapsedGameTime * someSpeed) % MathHelper.TwoPi;

raw warren

what is te current orbit angle connected to

is it x postion or y position

hot hazel

neither

it is an angle

raw warren

then how does it move

hot hazel

orbitPosition would be your sprite's position

raw warren

k

hot hazel

centerPosition is what you want to orbit around

raw warren

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

hot hazel

you have to save currentOrbitAngleRadius somewhere where it won't be reset every frame

raw warren

ok i solved

what about rotation

do you know how can i do it

it is a cylinder

hot hazel

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

raw warren

ok

thanks

do you know any equation for it

hot hazel

equation?

raw warren

or how to do this

or what exactly should i search for to get an answer

hot hazel

i just told you

raw warren

so i convert currenOrbitRadians to angle then add 90

and if anti clockwise i subtract 90

?

ok thanks it works now

raw warren

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?

hot hazel

You'll learn a lot more

raw warren

OK thanks

hot hazel

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)
hot hazel

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

^

serene phoenix

I'm gonna ask for libgdx help here

tough nacelle

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

tough nacelle
tough nacelle

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

azure geode

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

tough nacelle
azure geode

Using MonoGame is still 100% fine

tough nacelle

but its a game engine

azure geode
tough nacelle
hot hazel

monogame is a framework not an engine

tough nacelle

ok now im even more confused

thats what I said originaly

but both he and this said it was an engine

hot hazel

well that's just 'somewhere to put it'

tough nacelle

I would have put it under other dev

hot hazel

¯_(ツ)_/¯

azure geode

It's open source, pretty mature and has a decent community

tough nacelle
hot hazel

you arguably could, though it would be silly

but yes monogame is a framework not an engine, perfectly suitable for diy

tough nacelle

well I might be switching to silk.net or the C# version of opengl (I forgot the name)

tough nacelle

got it working

finaly

tough nacelle

I really gota find a way to have the models work with out me join all the pieces

hot hazel

as in not having to combine the meshes into one?

tough nacelle
hot hazel
tough nacelle

this is the model

hot hazel
tough nacelle
hot hazel

i need more technical detail...

typically for transforms you either use matrices or something like qual quaternions

tough nacelle
hot hazel

where are you getting stuck?

are you looking for help?

tough nacelle
tough nacelle
hot hazel

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)

tough nacelle

?

plain minnow

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:

normal yew

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

hot hazel

do you have any debug drawing capabilities?

normal yew

Hmh good one, unfortunately no. I'm not that experienced just yet but will look into that.

hot hazel

i recommend adding stuff like that where you can draw debug lines/shapes in-scene

normal yew

Will do that 😉 Thanks for the suggestion

devout burrow

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

iron zinc

can someone please tell me what's wrong with the load method in player
it keeps giving me that _animPlayer is null

hot hazel

likely an order of operations issue

esp since you're creating a new anim player for every instance

iron zinc
hot hazel

that is for you to decide, but it doesn't really make sense how you're doing it now

iron zinc

How would u normally do it

hot hazel
iron zinc
slate ravine

What's this channel for

hot hazel

it's in the name

slate ravine
hot hazel

game libraries

hot hazel
deep patio

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

north knoll

Let's collaborate. It's easy for me to fix game issues, and also I found it super convenient to develop a new game

raw warren

<@&133522354419662848> is this allowed or nah ther3s alot of it in this server tbh

humble lagoon

Hello

hot hazel

hi

unreal solar

Happy New Year!!!!!!!!

hot hazel

<@&133522354419662848>

cinder helm

Hi

weak void

hi felix!!

hot hazel

what do you mean using another medium?

silk oracle

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);
silk oracle

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

oblique plank

Does anyone have a good way to familiarize me with LibGDX please?

hot hazel
fierce shuttle

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?

fierce shuttle
vestal osprey

hello

jade peak

hello

foggy locust

so were not gonna talk ab how this person has a cursor on his phone?

hot hazel

plug in a mouse

earnest tulip

Could also just be an emulator

forest fossil

hello

oblique crow

Hi

plain jewel

<@&133522354419662848>

livid rampart

monogame love and support

hot hazel

<@&133522354419662848>

gritty jetty

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.

hot hazel
gritty jetty
modern bear

Hey does anyone have experience with libgdx? Would you recommend for a small game

livid rampart

Monogame engine library and project using that library commits so far

pale tree

Converting a .bat file game to monogame. Time to rewrite 14755 lines

last raven
pale tree

oh?

stray anvil

hello

royal needle

Hi, How are you?

livid rampart
livid rampart

After trial and tribulation of having to swap how my renderer handles ui calls, I now have some nice ui loaded in from json!

livid rampart

https://imgur.com/PqqUgbH

Testing out resource ui feedback, big fan of this but def need to add a setting to disable it lol

livid rampart

flickering was from layerDepth being too similar

livid rampart
dark vapor

rewriting my silly tetris clone from the ground up

one day I will work on real projects

livid rampart
dark vapor

cool new effects (again)

dark vapor

kool kounterz

dark vapor

sounds

shell schooner

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

hot hazel

it's not any different from 3d skeleton stuff fwiw

last raven
hot hazel
last raven
hot hazel

<@&133522354419662848>

upper knoll

Hello libgdx developers 🙂

What do u guys think about this kind of games ?

last raven

Random zigzag up a mountain. Width of the passage varies too. Padding on the left and right.

upper knoll

You mean this style ?

last raven
last raven
livid rampart

"fully" working menu, oml took a while

austere saddle

🚀✨ 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! 💫🎮

https://leandro-sapito.itch.io/astronave

round topaz

How to learn libGDX?

hot hazel
placid forge

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

hot hazel
round topaz
mint marsh

👋

mint marsh

👋