#monogame-and-libgdx-dev

1 messages ยท Page 2 of 1

frozen portal
#

though i guess i should sleep now

pearl ore
#

Seems fine except your js_emit method signature. have it take in a string dataStr instead of Object... args, pass in js_emit(event, data.toString()); instead, and make your JavaScript socket.emit(event, JSON.parse(dataStr));.

#

As is right now you're not doing anything with that JSONObject. You're populating it and then not using it

frozen portal
#

Done... but uhn

#

Here's what happens when compiling for HTML @pearl ore

#

I hope there's a problem with what I'm doing and not a conceptual problem

#

But the compileGwt does have to read all those imports, and instanciate some objects in Core

pearl ore
#

It can't find org.json in your core module I think

#

You need to add a dependency for it

frozen portal
#

Well I don't think it's a core thing as the Desktop ver runs fine

#

But I will try to add the dependency

#

Adding the dependency didn't work

#

I also can't add it to the GdxDefinition.gwt.xml since org.json isn't gwt compatible

#

what should I do?

pearl ore
#

Oh, I didn't account for org.json to not be GWT compatible ๐Ÿ˜‚ There goes that idea

frozen portal
#

yeah..

#

So what I could do is go back to using GWT JSON in the whole of my project

#

Though for that I will need to customize my Socket.IO library so that it works in GWT JSON and not org.json JSON @pearl ore

#

do you agree or is there still something better to do

#

There are 4 classes in Socket.IO that import org.json, Socket, Parser, Binary and HasBinary

frozen portal
#

oh wait the source I found on github is a newer version to the one I was using before, that could be a problem? should I try to look for the outdated one

#

or is it fine to use the newer version

frozen portal
#

Ok I managed to export it as a JAR, now I just gotta figure out how to put it in my IntelliJ project... exciting :)

#

huh

#

so I did everything and I still get class org.json.JSONObject cannot be cast to class com.google.gwt.json.client.JSONObject (org.json.JSONObject and com.google.gwt.json.client.JSONObject are in unnamed module of loader 'app')

#

i dont know what to do anymore @pearl ore

#

oh it's still using the old socket version, I guess I didn't import it right

frozen portal
#

what do you think?

pearl ore
#

Your idea of changing the socket.io to use GWT JSON is probably the better option. Should be straightforward, just a matter of adding the source code to your project and changing the references. I've had to do it before with KryoNet.

frozen portal
#

With a little luck I'll get this custom lib to work! ๐Ÿ˜„

flat osprey
#

Hi, Anyone about that wouldn't mind helping with a programming problem ? :)
I'm trying to add 10 different sprite images to a list so that I can call one of them at random each time I load a new level. The sprite will act as a background for that level. Is it possible?
in c#*

frozen portal
#

This is possible, but instead of loading 10 images and then randomly choosing one, it would be wiser to randomly chose to load 1 image

#

Do ask if I'm not being clear, I can't help you on the specifics since I don't know how to do LibGDX in C#

flat osprey
#

Yeh I just want to store them in the list, Then choose one at random that doesn't have a bool attached stating that its been used

frozen portal
#

Wait do you only wish to load the background when you start your game? or more than once after that?

#

if you mean chose a random one that hasnt been used before on launching the game you'll need to store that info in a file

flat osprey
#

Its not exactly loading a new level, But to replace the background image with a new one from a populated list of sprite / images

frozen portal
#

Okay so during the game's runtime you want to use all the background images, okay then your solution works fine

#

Load all of them and store them in a list

#

if possible use a TextureAtlas

#

it'd be a big, big file but hey you only need to open it when you start the game

flat osprey
#

Thats my problem, When I try to list.add(spritename) I'm getting an error "Cannot convert from 'AnimatedSprite.Sprite

frozen portal
#

to?

#

from AnimatedSprite to what

flat osprey
#

in this case.. toprojectname.Map_Generation.Maps

frozen portal
#

hmm are you sure you're calling the right list methods? again i dont have C# experience so I dont really know

#

but in any case your background should definitely not be stored in an "AnimatedSprite"

#

except if it's, well, animated

#

background should usually be stored as textures

sturdy prairie
#

where are you initializing your list? it seems you're trying to add an animatedsprite to a list of maps

flat osprey
#

How do I paste code here? The correct way I mean

sturdy prairie
#

```csharp
<put code here>```

flat osprey
#

Thanks

#
< List<Maps> mapList = new List<Maps>();
 sprite = new Sprite(game, texture2d, Vector2.Zero,1);
 mapOne = new Sprite(game, game.Content.Load<Texture2D>("Textures/Map_Sprites/Map_01"), Vector2.Zero, 1);>```
sturdy prairie
#

oh you don't need the < > actually, I was just representing code by that

flat osprey
#

ah ๐Ÿ˜„

sturdy prairie
#

as I suspected, your list is not a list of animated sprites, it's a list of maps

#

you cannot add an animated sprite to a list of maps

#

because it's not a map

flat osprey
#

Ahh, Thanks!!

#

Idk why I put Maps in there

sturdy prairie
#

np

frozen portal
#

there's a lot of fun stuff I have to do (I noticed my custom library actually didnt use the objects I told it to for some reason)

#

so now I have to code some functionality of JSONObjects that are in org.json but not in gwt json, like .put with one argument actually meaning append

#

and fun stuff like that

#

also org json JSONArray keys are ints whereas gwt json JSONArray keys are strings

#

t h e j o y o f c o d i n g

#

if I don't code in these functionality perfectly I'm opening myself up to a whole world of low-level problems I wouldnt have if they had just used gwt json from the start

frozen portal
#

@pearl ore do you know how to properly set up gradle?

misty bone
#

@frozen portal does anyone really?

frozen portal
#

seeing how hard it'd been so far Imma guess not

frozen portal
#

wait a minute I just re-read what Dr Loollipop said

#

You can get SOURCE code to work as a library?

#

I gotta figure out how

frozen portal
#

@pearl ore I only see info about importing JAR or "AAR" as local library, I don't know how to get the source to work

#

Should be straightforward, just a matter of adding the source code to your project hmm

#

Ohhh I'm dumb I understand

#

just add it inside source!

#

alright all good now I just have to fix the broken functionalities and cross my fingers

frozen portal
#

just how am I supposed to convert this object to a js object..

#

figured it out

pearl ore
#

Yeah, either add directly inside your project or you can create another module and put it in there. Doesn't matter really, just organization.

#

I'm probably not too helpful with Gradle anymore since it keep changing soooo much. I used to be pretty okay at it but that was like 4 years ago. Gradle 2.

frozen portal
#

I only have 3 problems left in terms of reproducing the old behavior with the GWT JSON objects rather than ORG ones

#

but boy they are tough to crack

#

especially since they're in some of the most important methods (emit...)

#

oh great, just noticed I'll have to also do this with Socket Engine.IO library since some parts use ORG json

#

the fun never ends, does it?

frozen portal
#

2 left, hype scratchcat

vale dew
#

is libgdx good for 2d games ?

pearl ore
#

You can use it for 2d and 3d games. It's a fully fledged framework. Most games made with LibGDX, though, are 2D games.

vale dew
#

ok thx

frozen portal
#

@pearl ore How do I turn JS Socket.IO into a DLL so that I may call System.loadLibrary() and make my code understand native functions?

#

(do tell me if any of that sounds off im just trying to get the native stuff to work)

pearl ore
#

That's only for C or C++. GWT should convert your functions for you. As far as socket.io, I can't remember off the top of my head unfortunately, you'll have to look up how to add JavaScript libraries so that they will show up in the HTML file.

frozen portal
#

this is damn impossible

vale dew
#

love2d or monogame or libgdx recommended for 2d games ?

frozen portal
#

Okay I think I figured out how to do the JS stuff, I'm getting hyped again

pearl ore
#

@vale dew Any. It basically comes down to which language you want to use. They're all solid frameworks.

misty bone
#

I found the C# dependency management ecosystem to be severely lacking when I tried out monogame a while back. On the other hand Java + Maven + Gradle is very robust and the community seems to publish things as maven repos pretty consistently (contrast with C# where "just copy paste the code from github to your project" seemed to be pretty common)

#

there also didn't seem to be any very mature/maintained/popular ECS libraries (if that's your preferred architecture) for C# + monogame when I messed around for a bit but I could have just not looked hard enough

#

Love2d I know nothing about

#

In terms of capabilities/general development style I think monogame and libgdx are very similar, likewise Java and C# are practically the same language with slightly different syntax

quiet ibex
#

there's plenty of ecs libs compatible with monogame, they're just not branded as such

#

since there's nothing monogame specific about your average ecs implementation

#

modern C# also has some tools that Java lacks, which can improve the performance of ECS implementations a lot (ref returns and Span<T> for example)

misty bone
#

I wasn't looking for monogame specific ones, what are the best ones?

quiet ibex
#

personally i like the fluent syntax one, i forget the name

#

there is room for performance enhancements, but its simple to use and versatile enough to fit most projects out of the box

misty bone
#

unless I'm missing something Behavior Trees != ECS

quiet ibex
#

ah my bad, read ecs but thought behavior tree

misty bone
#

still, that looks like a useful library, the kind of thing I would spend inordinate amounts of time building myself otherwise and ignoring the actual gamedev bits

quiet ibex
#

says its made for unity, but there doesn't seem to be any unity dependencies

pearl ore
#

Entitas is far more optimized, for sure. Mine is meant to be more simple.

misty bone
#

I'm all about simple/well designed API's

#

Ashley is the ECS I'm most used to

#

I think Entitas was the C# one that seemed best to me, can't remember why I gave up on it. Was probably just my frustration with the C# ecosystem

#

also turned off by "download the source to use", once I got used to just changing a version number in a config file to switch to a new version of a library I can't go back to that

frozen portal
#

@pearl ore I probably should have asked this before since this is paramount to our planned solution working, but

#

Do you know if there's a way to make the CompileGWT ignore certain files? in particular, the NonWeb implementation of my custom interface

#

if there isn't we're boned aren't we

pearl ore
#

Put the implementation in your desktop module instead. Doesn't make sense for it to be in core. core has the interface; the platform modules (html and desktop) supply the platform-specific implementation of that interface.

frozen portal
#

oh makes sense, ty

#

my final problem

#

after which i am freed

#

is that the JSONTokener class I need somewhere is part of google.gwt.thirdparty which... drumrolls

#

isn't GWT compatible

#

if I import third party, I can hook everything up just fine but it won't compile

#

so I need to do without it

#

p.data = new JSONTokener(str.substring(i)).nextValue();

#

this little guy is the only line left for me to solve

frozen portal
#

i... think I did it

#

i have to catch up on sleep, I'll update tomorrow if everything works

frozen portal
#

I can recieve all right but emitting is not easy

frozen portal
#

This isn't my game, but a repo I made so others won't have to go through this

#

I actually still haven't fixed stuff for my game yet but I have the proof it's possible

frozen portal
#

my game now fully works on browsers meeseeks_yelling

hearty grove
raw warren
#

a

hot hazel
#

b

raw warren
#

can xna tutorials be used for monogame?

hot hazel
#

100%

#

monogame is a superset of xna

raw warren
#

so i can fully use them

#

or would i havve to change some stuff?

hot hazel
#

should all work just fine

#

bugs in monogame notwithstanding

#

the API is the same

raw warren
#

Visual studio doesnt show monogame when creatingg a file

#

does anyone know hhow to fix this?

hot hazel
#

?

raw warren
#

I used the mmonoggame installler to install it

#

and i can open monogame pipeline

#

but nowhere in visual studio it givws me the option to create a project

hot hazel
#

ive had that issue

#

i just make an empty project and add all the monogame dependencies

#

(i dont use the content pipeline though so idk)

#

but look in the nuget packages for templates

verbal fox
#

Is monogame still being developed?

reef light
#

yes

#

monogame is the best

hot hazel
#

a slow project but yes

reef light
#

if you are using VS

#

not sure for other IDEs/platofrms

misty bone
#

libgdx: if I'm generating textures in code via Pixmaps (so they're unmanaged) then from what I understand when running in android I need to either store them to disk temporarily on @pause and reload from disk on @resume, or just regenerate from scratch on @resume, otherwise they will not exist anymore

Is this correct? The only info on exactly how this works I've found on google is from years ago

honest fjord
#

don't have to store on disk, regenerating is fine

#

static variables may need to be reassigned as well on resuming

#

the reason being the lifecycle for android; static variables are only initalized once at the start of codes execution, however, when "exiting" and "resuming", sometimes it doesn't recreate the whole thing, just calls create again

#

@misty bone

#

oh wait a sec haha, that's why i found that link, we were discussing this last week on the other discord ๐Ÿ˜›

misty bone
#

Object references to those unmanaged resources will be stale too right? The resume would have to pass them back into whatever classes need them after regenerating and replace the old reference?

#

Because the old ones point to some memory that doesn't actually have anything useful in it any more

modest apex
#

quick sanity check about monogame and vs for mac

#

I can't really verify this rn as my vs just froze but when I'm making a project, can I immediately build ports to other platforms outside of hte one I've chosen?

#

I see that when I'm selecting a template, I could choose the OS specific App templates, but I believe that only allows me to build and run the application immediately on the OS taht I'm developing on?

modest apex
#

actually should i just switch to vs17 for monogame dev

#

seems like there are a bunch of issues for vs19

hot hazel
#

ive not had issues on vs 19

#

if its easier, create the project in 17 and then migrate to vs 19

quiet ibex
#

anything platform-specific gets implemented in that platform's project, but normally thats somewhere between nothing and almost nothing

modest apex
#

@hot hazel are you using vs19 on mac or windows?

hot hazel
#

windows

#

vs mac != VS

native dagger
#

random question
Is there any lib or builtin thing on monogame related to interface?

All the games I've made using it have some interface I made myself, but it's incredible bad to code a 100% functional textbox, for example.

#

Makes sense, though, that since it's related to other platforms like xbox it doesn't have things for computer-only (since a xbox textbox is way easier to make)

quiet ibex
#

@native dagger if you target UWP, you can put those controls on top of your game

#

but most platforms require their own slightly different implementation, like xbox, mobile, ps4, etc.

#

but there are ppl who have made ui libraries containing textboxes in monogame, usually they only support keyboard input though

#

i doubt you'll find one that's feature-complete however

native dagger
#

Would it still have compatibility with Linux if I use UWP?

quiet ibex
#

no, if you use uwp, you'll need a separate solution for linux and mac

native dagger
#

Ugh

hot hazel
#

but your game code is all the same

#

so you just need a little bit of OS handling

native dagger
#

not experienced with that

compact willow
#

xbox textbox
Say that 5 times quickly

#

@reef light unfortunately the person you were answering (apparently a month ago) already left, but for future reference, the MG installer does not install VS templates for VS 2019, only 2013, 2015, and 2017
A quick google for "Monogame VS 2019 templates" should find them though

harsh glade
#

I apologize if this is pinned or otherwise answered elsewhere, but I'm new to Monogame, coming in from Unity. Does anyone have any suggestions for tutorials or other documentation on getting the most out of Monogame?

hot hazel
#

you'll find lots of XNA tutorials

#

monogame is a source (mostly) copy of xna

harsh glade
#

Sweet! Thanks!

quiet ibex
#

@harsh glade the content pipeline is one area i would dive a bit deeper on early. It can help save a lot of time by automating your asset processing, minimizing the need for manual labor when exporting whatever it is you've made

hot hazel
#

i skip the asset pipeline altogether

#

built my own content cache/importer in game and then just use native formats mostly

lament gyro
#

Yeah, I didn't like the content pipeline stuff too and made my own loaders. But I don't think i would start with this. @harsh glade The tutorials of rbwhitaker are really usefull, and microsoft has some nice xna tutorials too. At the beginning I would just try to get stuff on the screen and have fun. After that i would take a deeper look into vertex(declaration/buffer) stuff, to get a good understanding of what exactly is happening. Because Monogame is just a framework, that saves you a lot of basic coding, you probably will still need a good understanding of how graphics rendering is working in general at some point.

harsh glade
#

Ragath Thank you for that. That's definitely one that threw me a bit upon first look.

CobaltHex That sounds complicated!

Vicon Thanks for the info. That's where I'm at right now, just getting things to draw and update. Honestly, one of the reasons I grabbed Monogame is that I wanted a deeper understanding of these systems without making the massive time-commitment required to build them all from scratch.

lament gyro
#

Then you made a great choice! ๐Ÿ˜‰ I found playing around with creating my own vertexes and buffers by hand and drawing the infamous triangle with it is really a great way to get a good understanding of the framework.

quiet ibex
#

lots of ppl avoid the content pipeline because its usually skipped in the getting started tutorials, but its absolutely vital to have one when going cross-platform or dealing with assets more complicated than png files

lament gyro
#

you are right, getting content into the engine is really important part, but I wouldn't start with this.

verbal fox
#

Monogame doesn't have an editor, but what kind of features does it have compared to something like Godot?

quiet ibex
#

@verbal fox its a framework, so it lets you only use the features you need, making it possible to control the flow of the process at a much lower level

#

no object graph, no culling logic or other standard features enabled means specialized games that may not need it can be made simpler than otherwise possible

#

but if godot is a good fit for your project, then there's no reason to use anything else

hot hazel
#

@quiet ibex i skip it because its too rigid/limiting

#

i wrote my own basically

verbal fox
#

@quiet ibex So you're saying you had to write a tilerenderer yourself because monogame doesn't package the features you needed for it to work?

hot hazel
#

monogame is just a framework

#

it abstracts the os level stuff (graphics API, input) etc into a commont format

#

it is not an engine, it does not 'do' any logic for you

verbal fox
#

ah ok I see

#

Is libGDX also just a framework?

#

I'm pretty impressed with the games created in monogame considering it's not an engine

quiet ibex
#

@verbal fox yea, although i could've written a simple one in 3 lines of code or used one of the standard third party implementations available. but i wanted a fast tile renderer

#

and if you look here, it makes quite a difference on the achievable fps for most titles

#

most engines would struggle to go over 2k on an empty scene

#

with a standard tile renderer using nested for-loops i was around 2.3k

hot hazel
#

did you use shaders?

#

i ended writing a shader to maximize my tile renderer perf

lament gyro
#

I was thinking about writing a shader too... But atm I have no clear strategy for this, and atm other priorities. Im curious how you approached this.

quiet ibex
#

yea i wrote a shader for it, basically makes the gpu work like an old-school console when rendering tiles

hot hazel
#

heres my shader

#

simple pixel shader that renders your tilemap (stored as a texture) using some simple math in the quad

#

supports a camera transform

lament gyro
#

Thanks guys, this will defenetly help me! My map is procedurally generated and chunked etc, what results in quite some overhead for the cpu. I need to get some of the workload on the GPU. One additional idear is to only update the vertex buffer when there is actually a change on the map, or only do it with a low tickrate... Atm. the fps are defenetly too low.

hot hazel
#

just use a texture if its a tile map

coral monolith
#

Hey guys i am making a 2d Shooter game and i need a low latency connection between two phones on a local network For now i have set up a socket connection but don't know the best way to transfer data between them

#

for now my data is saved in a class that i want to send over the socket

#

and i tried ObjectOuputStream but it only sends me errors like this java.io.StreamCorruptedException: invalid stream header: 6E2E6A61

hot hazel
#

you may see if someone has pre-built a game specific networking library

coral monolith
#

i really don't need much i just need it to get points on a small school project

hot hazel
#

ok

#

well low latency is gonna require the use of UDP most likely

#

at least if you like FPS style performance

#

and you'll probably want to custom build packets with as little data as possible

coral monolith
#

so i'm working in libgdx

#

and my packets are as small as can get

#

though i have no idea

#

what or how to do the packet packing and unpacking

hot hazel
#

not ideal but if you have a fixed packet format you can also write to the network stream like writeByte(a.x); writeByte(a.y); etc

coral monolith
#

that is the problem it veries +- 2 bytes

hot hazel
#

make a fixed format if you can

#

use an enum/bool/flag to specify which version as well maybe

coral monolith
#

so how should i send the format than?

#

like a object as well?

hot hazel
#

you should use a flag specifying what the packet format is

#

and then have a fixed structure for that format

#

use a switch/if statements to read the packet data

#

if you can make a fixed size packet too that makes it a little easier

coral monolith
#

thank s ๐Ÿ™‚

hot hazel
#

theres lots of guides online

#

i cant help you in regards to java specifically

coral monolith
#

thanks it's okay i think i did alot of reserch today

#

so i might just know what i am doing ๐Ÿ˜›

#

i have been at this for like 10 hours now

hot hazel
#

its not trivial stuff

coral monolith
#

i'm gonna research it a bit more indeed ๐Ÿ˜›

hoary vault
#

If anyone could help me that would be awesome. https://imgur.com/a/r8dP7We
heres a screenshot of my two classes
when I hit the 1 key I would like to draw the sprite but I think I have something mixed up with references

#

I'm not sure if its an issue with the texture object being passed correctly or something else

hot hazel
#

what is the issue?

#

whats not working

lament gyro
#

I dont't know what your ISprite.Draw() does, but the issue should be, that you draw the sprite only once in the update loop after keypress, and then Draw() gets called everything is cleared and you dont see nothing

hot hazel
#

yes, set a bool or something if you wish to draw that frame

#

reset it every frame after that (or at the beginning of the frame before the check input)

#

alternatively you can check if a specific key was pressed or not and set the bool to draw based on that

#

(keyState.IsKeyDown/whatever)

hoary vault
#

oh yea i forgot about that

#

so is my issue that its only calling the draw function for one frame rather than until told otherwise?

lament gyro
#

well you draw in the update function... thats the first mistake

hoary vault
#

where does it show me drawing in the update function?

lament gyro
#

you ask for keypress in update and call the Setsprite that calls draw.

#

so you are stil in update of your main game

hoary vault
#

Hmm

#

thats how some of the example code for my class had it

hot hazel
#

one reason that can also fail is that draw and updates can happen at different rates

#

(so update might be called 1000x a frame where draw only 60)

#

(no guarantee of ^ but it might happen that way)

hoary vault
#

should i set the boolean in the keycontroller class and have one of them for each option?

#

i have this.TargetElapsedTime = new System.TimeSpan(0, 0, 0, 0, 150); // 33ms = 30fps

hot hazel
#

thats very much up to you and what you want to achieve

lament gyro
#

the clean way is to give the ISprite something like an "bool Enabled" prop. set that.

#

then put the draw of the sprite in the main draw and ask for that bool before calling it

hoary vault
#

ah

#

i only have one Isprite object in the main class though

#

so I would have 4 different booleans and 4 different calls to draw?

#

in the main class

lament gyro
#

no, you call the ISprite.draw ONCE!

hoary vault
#

Yea oops i was just about to correct myself

#

the keycontroller update method changes the sprite to the correct class

#

so i just need to change a boolean once a new key is pressed

#

right?

lament gyro
#

you need to save the reference of the sprite somewhere in main.

#

and on key press you can switch that out.

#

with another ISprite object

hoary vault
#

Okay got it

#

but that just never gets drawn since it changes

#

i have a LoadContent method I was doing that in when i was manually testing

lament gyro
#

you just call the reference in the main draw()

#

I have the feeling you are a little bit in the dark.

#

๐Ÿ˜‰

hoary vault
#

haha maybe

#

I've just never worked with interfaces before

lament gyro
#

you dont have to

hoary vault
#

i had it working "manually" wihtout the keyboard controller

lament gyro
#

I don't wanne be mean, but i think reading some basic drawing tutorials would help you a lot more then this chat.

hoary vault
#

I don't think I understand the game loop

#

fully

#

no i totally understand

lament gyro
#

i think you don't get referencing stuff with interfaces too

#

just put ISprite sprite on top of Game1.

#

in the keypress stuff write "sprite = new NotMovingSpriteblablabla" and in the Game1.draw() add "spirte?.draw()"

hoary vault
#

thats what i have

#

but isn't it game = new game1; and then game.sprite = new NotMovingAnimated(texture, row, column)

lament gyro
#

in your case game.sprite = new NotMovingAnimated() yes

#

do as i told you and it should work

hoary vault
#

its kind of working now

#

but I need it to not show anything until a key is pressed

#

should I just make a sprite class that doesn't draw anything or can i fix this with the boolean we were talking about earlier?

lament gyro
#

its super bad, but will work...

#

after "spirte?.Draw()" write "sprite = null"

#

the boolean is by far the better option lol

hoary vault
#

Hmm

#

I need to implement mouse clicks first and then I'll come back to the issue

#

looks like i got everything working

#

i just put if(draw) sprite.draw() and then put draw=true in SetSprite

#

does that sound like a good approach?

#

draw is initialized to false

#

thanks for your help @lament gyro i really appreciate it

restive tapirBOT
#

0reilly gave karma to Vicon

split warren
#

Can anyone help me, i m trying to create card turn while moving effect(crane effect like in hearthstone), in libgdx in 2d,
does anyone know how to achieve this?

hot hazel
#

got a vid?

silent plover
lament gyro
#

i don't know... it may be far superior with packet loss, but the graphs show losses of 10%-20%. this is ridiculous.

quiet ibex
#

@lament gyro rttp is just udp with retry, it usually beats tcp because you want reliable deliveries but dont care about the order

lament gyro
#

yes, i just wanted to point out, that the graphs are kind of insane. when do you have 20% packetloss?

quiet ibex
#

its quite plausible to have that during a short period of time

#

but normally you dont care about the ratio, the real difference is the number of packets you can lose in a row before things go bad

lament gyro
#

yeah, what you do depends mainly on what kind of game you wanna make.

quiet ibex
#

or how much of a multi-packet status update has to be delivered to call it a success

#

indeed, but pretty much all games have packets of varying importance, so being able to send unreliable, reliable and ordered packets all over the same connection is almost always beneficial

lament gyro
#

absolutely! thats why I would still default to lidgren, that has all sorts of modes.

#

and the unordered udp stuff sounds extremely hard to get working properly. I'd say if you dont require the speed, go with TCP for the sake of your mental health.

quiet ibex
#

its not that hard, you tag your packets with an id and keep sending them until you get a confirmation back

#

the only difference with ordered and unordered is whether or not you send more packets before recieving confirmaion

lament gyro
#

i think about a shooter scenario, where position data is all mixed up. so basically the player would move back and forth if you dont do any compensation.

quiet ibex
#

usually you send unreliable position updates and tag them with a timestamp, then just discard the ones that arrive out of order

lament gyro
#

yeah, but why resend them then? just forget about them like usual udp and you are fine.

quiet ibex
#

yea thats what i said: unreliable position updates

#

aka. plain udp

#

the firing actions you want to be reliable unordered though

lament gyro
#

basically what they do to confirm a hit is to rewind to the gamestate back when the shot happened (the package was send). crazy stuff.

quiet ibex
#

there's a divide there, most games do the shot when it arrives instead. benefits the person taking cover

#

source engine has suffered from ppl using a lag pedal and taking shots while pressing it

#

halo games also had that issue

#

quake engine and udk took the other route though

lament gyro
#

i think we can state, that netcode is a pain in the ass. ๐Ÿ˜„

quiet ibex
#

the most advanced version of this that i've seen is the ggpo tech used in fighting games though, but that one degrades exponentially based on the number of clients in the session

lament gyro
#

watch a gdc talk where they explained the tricks they used in a fighting game to make it feel smooth. but all those tricks... i don't think indies like us can pull it off.

quiet ibex
#

ggpo is the gold standard for fighting games and it was a couple of indies that invented it

#

its basically ignoring the gamestate and instead focusing fully on the input stream, trying to make sure everyone had a chance to act on any given frame

lament gyro
#

sounds a bit like the RTS approach of starcraft.

quiet ibex
#

well the big difference is the number of actions being dealt with, starcraft players may have crazy apm, but its nothing compared to the number of inputs generated by players in fighting games

#

so there are some key differences in how they deal with packet loss, but they are similar

lament gyro
#

the day I have to do my netcode is the day I fear the most... but I think i can get away with the minecraft approach. ๐Ÿ˜„

verbal fox
#

For monogame and visual studio on mac, is there a way to embed that terminal that pops up?

#

it makes a new window everytime you run the code

#

and it's getting quite nnoying to close all of them out

quiet ibex
#

You shouldn't be getting a terminal if you set the project up correctly

hot hazel
#

set your subsystem/whatever to windows not console

hot hazel
pearl ore
#

@verbal fox In your executable project's options

verbal fox
#

@pearl ore bless you

#

I'm such a stickler about my dev env and this makes it great.

#

now to actually start using monogame

#

Now that I'm in the development I have a couple questions:

  1. Does Monogame have it's own discord server that I can join?
  2. What resources do other devs typically use to learn monogame + pipeline
pearl ore
#

Not sure about Discord, this one is the only one I know of. I got started with XNA (MonoGame's goal is to reimplement XNA's since Microsoft axed it), my local library had some books on XNA 4.0 (Learning XNA 4.0, O'Reilly Media). You can use any tutorials online for MonoGame or XNA 4.0. The only thing different from XNA 4.0 is the content pipeline; instead of it being a project inside your solution, it's a separate application.

hot hazel
#

yeah refer to xna tutorials for any code examples/tutorials

#

theres some old IRC channels for XNA, but they're basically dead now

verbal fox
#

Is Monogame dead? I've really just been looking for a game engine/framework I can code my own systems instead of having massive overhead from engines like unity/godot

pearl ore
#

Far from it. It's actively in development.

hot hazel
#

slow, but active

verbal fox
#

What physics engine do you typically use for monogame?

hot hazel
#

2d or 3d?

verbal fox
#

2d

hot hazel
#

traditionally farseer was popular with XNA

#

looks like its been renamed velcro physics

quiet ibex
#

@verbal fox also important to consider if you actually want a physics engine, since most 2d games don't

#

for things like platformers or twin-stick shooters you normally just want the collision detection part

verbal fox
#

Hello, I'm having an issue in monogame where I have monogame install, but there are no templates available on my visual studio

pearl ore
#

The templates for the current release of MonoGame don't work on VS for Mac and only work for VS 2017. In VS 2019 the templates work if you copy them from VS 2017 but aren't installed with the installer.

verbal fox
#

oh i see, so I'll just need to make it with the command line

compact willow
#

You can also find downloads for the templates online, which you can plug right into VS 2019 @verbal fox

last pulsar
#

Heya, I've been interested in trying out monogame framework. Which version should I get with nuget? Redpoint modified seems to be the most popular.
For starters I'm just going to experiment on desktop, but building to web would be cool. Even better if I could wrap the code and build it to both.

#

Are there any templates I can get fom nuget?

compact willow
#

@last pulsar Redpoint's fork of MonoGame has been officially deprecated since 1st Jan 2018. Your best bet is to install MonoGame from the website (not from Nuget), and then if you really want additional functionality, look at either MonoGame.Extended or Nez

last pulsar
#

Ah, okay. Someone official said that they planned to phase out the installers and only rely on nuget. So that's where I started.

But I saw they had the templates on github, so I should have an entrypoint I can start with.

quiet ibex
#

@last pulsar the installers are being phased out, but that's still a few years away. You mainly need the installer to get the content pipeline, the project itself is best off using the official monogame nugets

vague swallow
last pulsar
#

Thanks, but I already got it running. Now I'm at the resource part, reading about the pipeline and if I can skip it for now (it seems it should be possible, but it's used for optimizations)

last pulsar
#

This might be a stupid question, but if I don't use the pipeline do I really have to have 3 instances of my resource (1 for the project asset folder with copy always/copy if newer, 1 for debug and 1 for release) Or is there a cleaner way of doing this while developing?

hot hazel
#

you just need to make your own asset manager

#

e.g. mine

#

(a bit complex, but basically create a dictionary<String (file info), IDisposable> { }

proper stone
#

No matter what I try the outlines dont go away ๐Ÿ˜ญ

raw warren
#

hi im having trouble setting up libGDX environment in eclipse on mav

#

mac*

#

i downloaded everything but it says i have 8 errors with the path after importing the gradle

native dagger
#

Is it possible to use GIFs and have enough control with them to replace regular image-sprites?
If so, is it better than image sprites?

#

If not, what's the best option for the sprites: a big file with all sprites I need or split each image in a different file?

compact willow
#

I'm not sure gifs would be ideal, and I don't think MonoGame supports them out of the box.
best option afaik would be a single sprite atlas, or at the very least a single atlas for each animation

native dagger
#

I see... I was planning to use one 'atlas' for each animation due to the limitations of image sizes to be loaded

#

Not sure, but well, thanks :D

quiet ibex
#

@native dagger even if you use a gif, you need to turn it into and atlas before rendering

#

there are lots of tools that can auto-generate atlasses at specific sizes for you though

vale dew
#

hello iam new to C# and monogame how can i make Timers ?

quiet ibex
#

@vale dew think about what a timer is, they have a starting point and then they measure how much time has passed until you take a look at it again. from this you should be able to identify that the data needed to be stored is a DateTime value and you need to compare it against another DateTime value when getting the elapsed time

#

i'll give you a hint and say that the GameTime object has a TotalElapsedTime property, containing the amount of time passed since the game started and the update/draw call was made

vale dew
#

@quiet ibex is there is no timer class or somthing ? i can do this but i thought there is a easier way

quiet ibex
#

there's system.diagnostics.timer but it doesn't measure game time, it measures real time

#

a timer class wouldn't make it any simpler, since you'd still need to initialize it and input the correct time value to compare against

vale dew
#

ok thanks

#

btw i like to program in C++ from time to another but when i open any C++ solution it closses and no error messages or crashes it just close

quiet ibex
#

i'd re-install the c++ parts of visual studio then

vale dew
#

the problem is that my visual studio installer run only one time then dont open idk why then i have to delete the installer folder to install it again what causes issues to visual studio and have do re-download again happened to me twice

quiet ibex
#

sounds like its time to re-install windows

vale dew
#

yep my pc is dying i want to upgrade it but i dont

#

ok thanks i can work with C# for this time

hot hazel
#

you can try also deleting all your profile settings to VS

#

~/AppData/{Local|Roaming}/Microsoft/VisualStudio

quiet ibex
#

that's not going to fix a broken windows installer runtime though

hot hazel
#

i need more info about what is happening

vale dew
#

how can i pass function as paremter ? or at least a refrence to it

#

and dont worry about the installer now i dont use C++ for now

compact willow
#

@vale dew in C#?
You can use the Func<> generic type if the function you wish to pass has a return type, and the Action<> generic type otherwise

vale dew
#

@compact willow iam making a timer class and i want to do

if (this.time <= 0){
 this.function();
}

and i want this.function to be set by a paremeter when new object created (sorry for english)

compact willow
#

so the function will have a void return type and no arguments?

vale dew
#

it may have a arguments but i set them when creating the new object

compact willow
#

the function's footprint needs to be absolute to pass it as an argument

vale dew
#

ok i have to go to study now will try again when i comeback

hot hazel
#

you can use any delegate

#

Action<T> and Func<T> are just convenient generic options

quiet ibex
#

@vale dew you have to remember that the method you're passing the delegate to has to be able to invoke it

#

Func<> and Action<> covers all the method signatures that you should ever need

#

if you know some arguments ahead of time, you could make an invoker object that holds both the arguments and the delegate and invoke that

hot hazel
#

theres also standard EventArgs<T> if you are doing events

quiet ibex
#

you end up passing junk through them though, so unless you have a really good reason to pass a mostly useless object around, avoid them

hot hazel
#

i wrote my own event handlers for my UI code

#

event system*

hot hazel
#

explicit delegates are nice but not necessary

orchid frigate
#

Hello there,

Got a small problem with my current Monogame project. I did rewrite an old game I did write back in 2015 with a friend of mine.
For the core system I did write a ECS system which consists of the following interfaces

IGameEngine
IEntityManager
IEventManager

The game manager holds a instance if an implementation of the entity- and eventManager interfaces.

Know I was thinking about adding some kind of screen mechanic so that I can create a instance for example the main-, setting menu or the game itself. Each screen is part of a manager class which is a finite state machine. Only one screen could be active at once and each screen can create a transition to another screen by either creating a instance and push it to the FSM or by pop itself so the last screen is reactivated.

Now I was thinking what to do with the "game engine" instance holding the components, entitles and systems there a two possible scenarios in my head but both just doesn't sound right.

Passing the "ECS" container around between the screens clearing the content between the screens

  • This would get me into trouble restoring an old state from a previous screen because I did clear the entites. caching the entites, components and systems in the screen and freeze them to add them later on seems fishy

Create a new "ECS" instance for each screen. Because only one screen is active at the time only one ECS would be updated and drawn but somehow my mind thinks this idea is not right as well

Is there something I do miss or is my mind just playing tricks to me and one of the solutions is totally fine?

hot hazel
#

what are these 'screens'

#

shouldnt only one need an ECS? (also id separate the ECS from the screens, maybe put it into a game container you can pass around if necessary)

#

(your game engine is the ECS)

#

also i dont think you need it to be an interface, presumably theres only one version of it

orchid frigate
#

A screen is some class implementing a interface
This "screen" should represent a state of the game such as a game menu

I think in unity this is called "scene"

#

The ECS itself is a "GameEngine" instance which holds a "EntityManager" and a "EventManager"

hot hazel
#

yeah, still seems like a spearate concept from your ECS

#

in my game, there is the UI code, which is any UI

#

the game and editor containers are both UI

#

the game and editor just have a reference to the current map/game instance

#

they're responsible for scheduling updating/drawing/etc the game, but the game itself handles everything game related

orchid frigate
#

So let's think about the following situation

I do start the game the ECS is filled with an entity per UI element with the components and systems needed to get everything into a working state

Now I click on the start game button

If I clear the entities in the manager everything is gone, which is okay in this situation

If I stick to this solution if I want to implement a pause menu in the game I need to delete all entities which will prevent me from restoring the old game state

I can't get my head around this problem ๐Ÿ˜ฆ

hot hazel
#

why is your game code coupled to the UI like that?

#

why do you need to delete entities to display a pause menu?

orchid frigate
#

I could add a "disabled component" to them to tag them as inactive

#

Which could be implemented into the systems to stop watching all entitles which are tagged as disabled

hot hazel
#

still dont know why these two things are coupled like this

orchid frigate
#

Do you know the Entity Component System?

#

Maybe I did implement something wrong

hot hazel
#

yes

compact willow
#

ECS is not a catch-all solution

hot hazel
#

i still dont understand the relationship between your game entities and your UI code

orchid frigate
#

ECS is not a catch-all solution
@compact willow I know that it's just another way to represent your game entites
And the system is not the solution for every problem for the game structure

compact willow
#

right and the architecture need not be ubiquitous

orchid frigate
#

right and the architecture need not be ubiquitous
@compact willow So it is totally valid to use the ECS only in the game itself
For other screens like the menu something simpler could be used?

compact willow
#

Right. Only use ECS where ECS is warranted.
And always make sure that your UI logic is completely decoupled from your game logic

hot hazel
#

you can also have an ECS for your UI and an ECS for your entities

#

or even if you combine them, the UI can be loosely coupled to your game entities

compact willow
#

that too

#

I've been told that ECS is deceptively good for UI work

orchid frigate
#

i still dont understand the relationship between your game entities and your UI code
@hot hazel At the moment In my thinking an UI element is a entity with components representing the element

As example an visibleComponen
An PositionComponen
And clickableComponent

Some system is doing the logic

That's why in my head the things are so tightly coupled

hot hazel
#

well if you want, you could have an EntityHUD system or something?

#

theres several ways you could handle this

#

but you are going to likely want a UI hierarchy/tree

#

and all entity UIs go into one node

#

your pause menu/game code could disable the entity UI while the pause menu is active

orchid frigate
#

So to rethink the whole problem:

There are screen/scenes which can use different systems
As example the game screen could use the ecs while a "menu screen" is using a Object-Oriented data structure to represent a UI

Each screen is a own set of logic and data?

So using a different system per screen is totally normal

Because my next "problem" was how to create a text box with ECS where I need a system keeping track of the buttons firing events like crazy ๐Ÿ˜„

#

Is this correct?

hot hazel
#

i would decouple the UI from the ecs

#

if you want your entities to have UIs make a system/component that interfaces with your UI system

orchid frigate
#

Hmm there is no real UI in the game

The game is some kind of cannon hill clone
So there could be some health bars
A gui showing the direction and force of the canon

Any some kind of box where you can see which projectile you did select and how many are left

#

So I think I will use the old approach before creating the ECS

I will create a new UI system which is working correctly :D
Use a screenmanager to get transitions and use the ECS only in the game itself ๐Ÿ™‚

#

thanks @hot hazel

restive tapirBOT
#

Xanatos gave karma to CobaltHex

orchid frigate
#

thanks @compact willow

restive tapirBOT
#

Xanatos gave karma to Kaho

gray heron
#

How does monogame compare to libgdx? Is it better at cross compiling to targets?

compact willow
#

@gray heron according to their website, libgdx supports building for Windows, Mac, Linux, Android, iOS, BlackBerry and HTML5.

MonoGame supports building for Windows, Mac, Linux, iOS, Android, tvOS, PlayStation 4, PlayStation Vita, Xbox One and Nintendo Switch

#

So monogame has better (ie: has) smarttv and console support, but libgdx has slightly better mobile support, and web support

gray heron
#

Yea they claim that but I'm just wondering if someone actually has experience with the two

#

and blackberry doesn't count lol

#

its really just ios + android, I need top notch support for them two

compact willow
#

(MonoGame also supports windows phone but.. y'know)

vale dew
#

ok i have a problem and i dont know why it happens
iam making a clicker game and this happen when i try to handle clicking with event handler

public EventHandler click;
public void update(gameTime dt){
  if type == "first" {
   this.score_increasment = 1;
   this.click += new EventHandler(delegate (Object sender,EventArgs e)
                {
                Game1.score += this.score;
                });     
}
if (this.mstaten.LeftButton == ButtonState.Pressed && mstateo.LeftButton == ButtonState.Released && this.rec.Contains(mousePosition))
            {
                click.Invoke(this,new EventArgs());
            }
}

and when i run it it increase the score with random number instade of 1

#

ok nvm i fixid it

#

it works when i put it in the constructor instade of update

compact willow
#

well yeah with that code you're adding the event listener on every update

proper stone
#

Would creating an editor for my monogame engine(if you can call it that) be worthwhile?

#

If so, where would I even start? lol

hot hazel
#

depends on what you want

#

may make it easier

#

if thirdparty tools work why bother

#

my game has an editor built in so that in theory others could make content

#

(should anyone ever play my game ๐Ÿ™‚ )

proper stone
#

@hot hazel What did you use for your editor?

#

Just ingame gui?

hot hazel
#

i made everything

#

but yes its using my gui code

proper stone
#

Ah gotcha

quiet ibex
#

@proper stone first you need to figure out something that makes your editor special enough to be worth making. Since you're probably gonna spend somewhere between 80 and 800 hours making it

#

assuming its a relatively simple editor tailored specifically for the game your making

#

if you don't expect to save at least twice that by partially automating your tasks, then don't bother. Better off spending 8-40h writing pipeline extensions for editors that fit your need

hot hazel
#

fuck pipeline extensions

#

just write it into your game code

quiet ibex
#

sure, as long as you only ship on one platform, don't care about the size of your game and never plan to ship asset updates

#

oh and dont care about load times

hot hazel
#

none of those things are restricted to a pre-compile content pipeline

#

also you dont have to use the monogame one

#

if you're making an AAA 3d game sure

proper stone
#

@quiet ibex I just want to do it for fun

#

For the experience

peak nacelle
#

Anyone here?

#

I am trying to make a rectangle that will cover the background

 graphics.PreferredBackBufferWidth = 1200; // Game Width
            graphics.PreferredBackBufferHeight = 700; // Game Height
            graphics.ApplyChanges();
#

I created this but it doesnt seem to work

 Rectangle Screen = new Rectangle(0, 0, 1200, 700);
#

doesnt the resolution start from 0, 0

hot hazel
#

how are you rendering it?

#

spritebatch?

quiet ibex
#

@peak nacelle a Rectangle is just a struct that describes the position and dimensions of a rectangle, its not visible unless you draw something looking like it

peak nacelle
#

Im not drawing it

#

I want it to use is for

#

.Interacts

#

So i dont need to

frigid dagger
#

@peak nacelle the 0 position of the X and Y axis is not tied to the screen itself

#

you should set the X and Y to Game1.GraphicsDevice.Viewport.X and Game1.GraphicsDevice.Viewport.Y

#

X and Y in the way that you are using them are just world coordinates, when working with UI it is good to use screen coordinates

#

if you have a camera that moves around the world your X and Y positions will be left behind

#

also you said .Interacts I hope you didnt just type the method incorrectly in your code it should be .Intersects

peak nacelle
#

Yeah thanks

proper stone
peak nacelle
#
Rectangle Screen = new Rectangle(0, 0, 1200, 700);
            Rectangle Tank2Rectangle = new Rectangle((int)Tank1[0].Position.X - 68, (int)Tank1[0].Position.Y - 29, 98, 60);
            Rectangle TankRectangle = new Rectangle((int)Tank[0].Position.X - 68, (int)Tank[0].Position.Y - 29, 98, 60);

            bool inBound;

            if (TankRectangle.Intersects(Screen) || Tank2Rectangle.Intersects(Screen))
            {
                inBound = true;
            }
            else
            {
                inBound = false;
            }

            if (inBound == false)
            {
                Tank1[0].Position += Tank1[0].Direction * -5f;
                Tank[0].Position += Tank[0].Direction * -5f;
            }
#

shoudnt these recrangles intersect?
idk why they dont
or at least if they do
my if statements dont work

#

If the screen rectangle is in the tankrectangle when the game loads
will this affect it?
does .intersect mean they first dont have to intersect

quiet ibex
#

@peak nacelle use breakpoints and inspect your variables, the positions are probably not what you think they are

#

and you might as well do csharp if (!TankRectangle.Intersects(Screen) && !Tank2Rectangle.Intersects(Screen)) { Tank1[0].Position += Tank1[0].Direction * -5f; Tank[0].Position += Tank[0].Direction * -5f; }

peak nacelle
#

yeah they are not what they are supposed to be

#

false instead of true

#

idk why

#

i drew the rectangles

#

and they are correct

#

they should intersect

plush acorn
#

I am not exactly sure if intersects works when on rectangle is completrly inside the other @peak nacelle

peak nacelle
#

yeah i think so too

#

what else can i use tho?

plush acorn
#

I think you can impmement your own AABB

#

Or if u want rotatuins some OOBB would be good to go to

quiet ibex
#

@peak nacelle the standard rectangle intersection works for all cases, have you inspected the values live, or just deduced what they should be by looking at the code?

peak nacelle
#

i drew the rectangles

#

and i know for a fact

#

the tankrectangle

#

is inside the screen rectangle

#

when game loads

#

but the code says

#

its not

#

i @quiet ibex

quiet ibex
#

@peak nacelle then you didn't check the actual values, you need to use the debugger

frigid dagger
#

rectangles can intersect other rectangles that are 1pixel x 1pixel large, a full rectangle overlap will still count as an intersect

#

i have used a 1pixel rectangle at the point of my mouse cursor to show intersects with my mouse and other rectangles

#

@peak nacelle just start typing Console.Writeline(Tank2Rectangle) or Console.Writeline(inBound) in different parts of the code and watch for any relevant data on the console when you launch your program

#

we dont know what your Position value, and you offset the rectangle of your tank by 68 pixels to the left of your position, so maybe the tank is off screen by 68 pixels

#

you can also try building your screen rectangle to be half the size of your actual screen so you can see if anything is happening outside the Screen rectangle

#

also show us what your direction vector is looking at and explain why you are using negative velocity, you want the tanks to move away from the screen when they leave the boundary?

peak nacelle
#

Its fine melt

#

i fixed it

#

using another method

#

idk why it didnt work

#

@frigid dagger

#

r u online?

#

How can i make an effect stop playing?

#

i used

#
if (Keyboard.GetState().IsKeyDown(Keys.W))
            {
                Position += Direction * LinearVelocity;
                effect.Play();
            }
#

but i cant find something that will stop it from playing

hot hazel
#

is that a sound effect?

#

if so, that returns a SoundEffectInstance that has Play/Stop/etc on it

peak nacelle
#

Ok thanks

flat osprey
#

Hey all, Anyone about that uses monogame and willing to spare a min? ๐Ÿ™‚

hot hazel
#

!dontask

restive tapirBOT
hot hazel
#

@flat osprey ^

flat osprey
#

Ah cool, I managed to sort my previous problem but now I have a new one haha. Do you know how to resize a texture in monogame by any chance? ๐Ÿ˜„

#

Also.. I mean like how could you set a percentage for scale, Using rectangles atm to try and scale it

wide lava
#

As we uses libgdx, feel free to ask anything about coding.

hot hazel
wide lava
#

@hot hazel Ok. I delete that post. ๐Ÿ‘

frigid dagger
#

@flat osprey
if you are trying to scale individuals sprites you can draw them with method 5 of 7 in spriteBatch.Draw
spriteBatch.Draw(texture, rectangle, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 1f);
your first rectangle is the physical rectangle of your sprite, the sourceRectangle is used on your texture to find the coordinates and size of the sprite you are using
so if you upload an image that is 32*32 pixels in the top left corner of your sheet, you can identify the source as (0, 0, 32, 32)
now you can make your actual in game rectangle to be new Rectangle(positionX, positionY, 32 * 2, 32 * 2) this means you will represent the source image 2 * larger
if you want to use a percentage of scale you can make a quick conversion,
int percentageScale = 100;
float trueScale = percentageScale / 100;
and then use trueScale on your rectangles width and height fields, the width and height of a rectangle cant be represented by a float but you might have a 150% value in some cases so create the width and height of your rectangle separately then use it in the rectangle as an int.

Alternatively you can scale sprites using method 6 of 7 of draw. In this case there is a field that takes a float scale with 0f value being no scaling applied.
this method doesnt use rectangles for positioning, it applies the scaling onto whatever your source rectangle is, and positions the sprite at a vector2

#

the final method is applying a scale to your entire spriteBatch by use of a scale matrix
create a matrix somewhere that you will access it in your spriteBatch.Begin method
Matrix scale = Matrix.CreateScale(1f);
and use overload 5 of 5 in your spritebatch.begin
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, scale);
this is the most vanilla way to create a spritebatch with a scale added and not worrying about other fields.
the scale of a matrix should be 1f to show 100% of your sprites size, but just as earlier you can change the float to 1.5f etc. if you feed it an int of 150

hot hazel
#

i would advise not using the percentageScale, id also recommend using floats all around, you'll get a lot more precision

vale dew
#

so i was looking for a timer and found System.Timer and its good but when i want to make like dealy betwen action and another and it make the code complecated and big so is there is any way i can do it ?

tribal compass
#

I'm not sure what you're trying to do exactly but you probably want the monogame timer over system.timer

vale dew
#

i want to make it like after(x,somthing_to_do) or every(x,somthing_to_do) and like this

quiet ibex
#

@vale dew here's the thing, its a lot more complicated than that. You have to remember that the simulation updated in increments, so you'll be timing your stuff to coincide with an update/draw and depending on what you're doing, you may need to compensate for the action happening late

#

so what you really need is a scheduler, so you can say "invoke this action in that timeslot"

#

this way you'll be able to schedule things and still maintain the execution order in each update/draw

tribal compass
#

if i want to use a 16x16 tileset for a top-down, but those tiles are too small on the screen (1920x1080) is the best way to increase the size to use scale 2.0 in Draw()?

#

It looks a little fuzzy when i do that

quiet ibex
#

@tribal compass there are various ways of going about it, but the simplest one would be to switch sampler state to point sample

tribal compass
#

do you have a docs link? I'm not sure how to do that

quiet ibex
#

its a parameter you pass to spritebatch.Begin()

tribal compass
#

ah

#

okay i'll try that, thanks

frigid dagger
#

@vale dew heres an example of a timer using monogames gametime.
double timer;

inside your Update(gameTime)
{

timer += gameTime.ElapsedGameTime.TotalMilliseconds; //this returns the number of milliseconds passed since last update in a 60 frame game it is usually 16ms

if(timer >= 1000) //1000 is milliseconds - so 1 second
{
//perform action here
timer = 0; //set the timer back down to 0
}
}

#

you basically want to create a variable that counts up by 16 milliseconds every single game loop and when the milliseconds reach your desired number you perform your action and reset the timer to 0 so it can start counting again

tribal compass
#

Does anyone have a guide on programmatically determining tiles based on a grid in a top down game?

#
G G G G
G D D G
G G D G
G G G G
#

like what's the best practice for drawing the correct tiles in each position here, assuming G is grass, D is dirt, and the tileset has a tile for every corner

quiet ibex
#

@tribal compass you'd want to read up on Wang Tiles, by storing your information slightly differently you can index the tiles directly using it

#

but for a corner, you'd do a walk around the tile, starting at the top and checking 3 tiles, if the second tile is empty and the other 2 are filled, then its a corner

#

you'd need to run that check 4 times for every tile, so you still want to bake the result

tribal compass
#

I was able to get most of the way there last night by building an algorithm that does the walking and checking

#

Still some bugs to work out, but that seems like the only solution.

#

Every time a player changes the tile, the algorithm checks the neighbors of all affected tiles adjacent.

#

And updates the map appropriately

lament gyro
#

@tribal compass I did something like that. the issue comes from the amount of tile types you have. If you check the center tile + the surrounding you need to basically check the 3x3 grid. So you have 2^9=512 possible patterns. if you have 3 its 3^9=19683 possible patterns... depending on what you try to do, you run into a complexity issue.

hot hazel
#

@frigid dagger i do not recommend keeping time in a double like that

#

id do something morel ike ```TimeSpan lastUpdate;
void Update(GameTime gameTime) {
if (gameTime.TotalGameTime > lastUpdate + TimeSpan.FromSeconds(1)) {
...;
lastUpdate = gameTime.TotalGameTime;
}
}

tribal compass
#

@lament gyro There are a lot of possible patterns, but I only run the check on the affected tiles with every click, only when the tiles actually change. I then save the results to the map. It's complex, but it doesn't have an impact on performance that I've detected. Hopefully down the road when its time to do some refactoring I'll find ways to make improvements.

lament gyro
#

What I did, was creating a dictionary with the tile patterns as the key that returns the texture index as value.

tribal compass
#

yeah, that's the map

#

the player can change the map, so i need to have an algorithm pick t he right texture

#

to reference

lament gyro
#

have you programmed it by hand with if then elses or what was your approach?

tribal compass
#

i do all my programming with my hands

#

two for loops, i and j from -1 to 1 around the clicked square

#

that handles all the surrounding squares

#

each square i look at all of those surrounding squares

#

and i have a clunky set of boolean logic for each potential tile

#

in if-else

#
                !IsDirt(Map[x - 1, y - 1]) && !IsDirt(Map[x, y - 1]) && !IsDirt(Map[x + 1, y - 1]) &&
                !IsDirt(Map[x - 1, y])     &&                           !IsDirt(Map[x + 1, y])     &&
                !IsDirt(Map[x - 1, y + 1]) && !IsDirt(Map[x, y + 1]) &&  IsDirt(Map[x + 1, y + 1])
            )
            {
                Map[x, y].Sprite = TileSprite.TopLeft;
            }```
lament gyro
#

that is the exact thing I did at first too.

#

but I ran into issues with it when I wanted my map to be more komplex

#

like having gras, dirt, sand, mud, and so on tiles... maybe some water ontop of it

tribal compass
#

my design wouldn't allow for a tile to be more than one thing and it would not allow the player to modify a square in contact with 'blocked' tiles

#

so i think as long as my logic doesn't break it should be fine

lament gyro
#

then stick with it

tribal compass
#

but my tile system isn't going to be more than water, dirt, grass, or tree

#

at least in this part of the game where the player can modify the ground

lament gyro
#

I'm just asking, because I ran into a lot of problems when trying the same thing 2-3 months ago.

#

but I didn't want to enforce "map creation" rules, because my map is randomly generated... It was a lot more difficult then i thought at first

tribal compass
#

yeah that's why i'm not trying to do procedural/generated maps

#

its hard enough to get this part to work for now

#

but i imagine it comes down to careful, meticulous organization

#

because as far as i can tell there are no short cuts

lament gyro
#

If you want to see a great ingame map editor in action, you can take a look at rise to ruins. helped me a lot in understanding some approaches.

tribal compass
#

its not in scope for my current project, but i'll keep it in mind

#

the best i've seen so far is dwarf fortress

lament gyro
#

I just know the ascii one, never dug into it. :\

tribal compass
#

that's the one

#

you can add tilesets

#

there are plenty

#

its map generation is far more impressive than anything else i've seen

#

i just wish they could figure out some of the performance problems in the game

orchid frigate
#

I'm totally confused right now :D

I did write a wrapper class for the keyboard class so I can use it with my dynamic controls system

class KeyboardWrapper
    {
        private KeyboardState previousKeyState;
        private KeyboardState currentKeyState;

        public void UpdateState()
        {         
            Console.WriteLine("currentState: " + previousKeyState.IsKeyUp(Keys.Space));
            Console.WriteLine("StateToSet: " + currentKeyState.IsKeyUp(Keys.Space));
            previousKeyState = currentKeyState;
            //Console.WriteLine("newState: " + previousKeyState.IsKeyUp(Keys.Space));
            currentKeyState = Keyboard.GetState();

            Console.WriteLine("RealState: " + currentKeyState.IsKeyUp(Keys.Space));

        }

        public KeyboardState GetState()
        {
            UpdateState();
            return currentKeyState;
        }

        public KeyboardState GetPreviousState()
        {
            return previousKeyState;
        }

        public bool IsKeyDown(Keys key)
        {
            return GetState().IsKeyDown(key);
        }

        public bool IsKeyUp(Keys key)
        {
            return GetState().IsKeyUp(key);
        }

        public bool IsKeyPressed(Keys key)
        {
            //bool currentDown = currentKeyState.IsKeyDown(key);
            //bool previousUp = previousKeyState.IsKeyUp(key);

            //return currentDown && previousUp;
            return false;
        }

Now if I press the space key I check on the UpdateState the "currentKeyState" is always true. Anyone can spot my mistake?

currentState: True
StateToSet: True
RealState: False

#
    class StaticKeyboardControls : IGameObjectController
    {
        private readonly KeyboardWrapper keyboardWrapper;

        private Keys fire = Keys.Space;
        public Keys Fire => fire;

        private Keys strenghtUp = Keys.W;
        public Keys StrenghtUp => strenghtUp;

        private Keys strenghtDown = Keys.S;
        public Keys StrenghtDown => strenghtDown;

        private Keys rotationUp = Keys.A;
        public Keys RotationUp => rotationUp;

        private Keys rotationDown = Keys.D;
        public Keys RotationDown => rotationDown;

        public StaticKeyboardControls()
        {
            keyboardWrapper = new KeyboardWrapper();
        }

        public bool IsFirePressed()
        {
            keyboardWrapper.UpdateState();
            return keyboardWrapper.IsKeyPressed(fire);
        }
    }

Thats the current implementation of the class using the wrapper, the idea is to provide a interface which can be a controller or a keyboard
The class is not done yet.

I do call it for testing purpose on the Update function

            var test = new StaticKeyboardControls();
            if (test.IsFirePressed())
            {
                //Console.WriteLine("Fire!");
            }

AND I think I did spot my error just yet -.- creating a new instance in every update is not a good idea :D

Thank you for reading this ๐Ÿ˜„

#

Now it is working, stupid me ๐Ÿ˜„ -.-

quiet ibex
#

@orchid frigate you want to make sure the update in th wrapper happens only once per frame

#

otherwise you'll miss presses and releases

tribal compass
#

Has anyone run into issues with using static classes to handle common functions used across the game?

#

performance-wise

#

I have an inventory interface and I don't want to avoid re-writing common actions like adding things to the inventory

quiet ibex
#

@tribal compass a static method is the least costly method to invoke, although for the most part a member method has the same invocation cost

#

and if you're gonna make it static, you should consider making it an extension method, if one of the parameters are clearly the intended context

tribal compass
#

okay that's what i figured

#

i'm not a fan of extension methods, but that's just a personal thing

quiet ibex
#

why not? makes your api far more discoverable

tribal compass
quiet ibex
#

@tribal compass did you even read that article? he was arguing against turning instance methods into static methods, not against extension methods themselves

tribal compass
#

i understand

#

contains a lot of the points i don't like about extension methods

#

anyways, i'm trying to figure out how to do what i'm looking to do and I don't have the answer quite yet

#

don't really appreciate the accusation that i didn't read an article i used as justification, don't really understand why that was necessary

quiet ibex
#

well you said you didn't like them and cited the article, presumably as the reason for why

tribal compass
#

correct

#

and it is still the reason why

#

i don't like statics in general so i'm looking for a better solution

quiet ibex
#

well you gotta do inheritance-based oop then

tribal compass
#

hmmm

#

probably going to go with dependency injection that i followed at one of my previous jobs

quiet ibex
#

why means you need to know which data you need up front, so you can slice it up into objects suitable for the problem at hand

#

dependency injection solves a completely different problem though

tribal compass
#

ok

quiet ibex
#

since its all about the initialization andgetting the data to the right place

#

wont solve stuff like adding items to an inventory

tribal compass
#

I can use the constructor of the Inventory to have its own instance of InventoryManager

quiet ibex
#

sure, but then you're using InventoryManager like a static class, ending up with the stuff you said you wanted to avoid

tribal compass
#

no, i'm good with it working that way

#

easy to mock for unit testing

#

avoids statics

#

doesn't hide implementation

#

can enforce things through the IInventory interface

quiet ibex
#

normally you'd want to mock data, not functionality

tribal compass
#

If i need to unit test Inventory, and it has a property InventoryManager, I'll need to create a mock of Inventorymanager

#

Or else my unit test is also testing InventoryManager

quiet ibex
#

and if you have static methods then you'd mock the inventory to test the methods

tribal compass
#

yes but then i'm using static methods

#

which i would liek to avoid

quiet ibex
#

so i dont see how using the manager pattern would make things easier to mock here

#

i'm not saying use static methods, i'm just not seeing how they're bad for mocking

tribal compass
#

i didn't make any comment on whether or not static methods were easer/harder to mock

#

the pattern I'm currently sold on allows me to mock the properties in my classes

#

that's all

quiet ibex
#

fair enough, didn't think you where running a monologue there

tribal compass
#

ok

raw warren
#

Any engine programmers here?

hot hazel
#

!dontask

restive tapirBOT
loud sonnet
#

@raw warren everyone is making some sort of engine here

mighty dagger
#

I'm trying to achieve something similar to terraria or minecraft's collision system where you can fall down a 1x1 hole and not get stuck on the corners

hot hazel
#

got a video/gif?

#

also i recommend something like github

mighty dagger
#

I made some changes to it so let me make a quick gif

#

(changes since the last gif I made, the code is current)

hot hazel
#

i would prefer not to read an entire project of code

mighty dagger
#

hold on imgur is not letting me upload the gif

#

I'm going to make a webm instead

#

pretty much everything is in Actor.cs which is the pastebin link, but I included all of the relevant code in a zip on the google drive link just in case

hot hazel
#

first step would be to shrink the AABB

#

i recommend drawing it overtop the player as like a red rect or something

#

so you can see where its getting stuck

mighty dagger
#

Good idea, I really should have just drawn some debugging stuff. Just added it and it looks like my AABB is actually working fairly close to how I want it to, but my player is not being updated properly

hot hazel
#

id draw an open rectangle above the player for better clarity

#

also maybe if you can highlight collisions

#

but it doesnt look like it perfectly matches the player

#

it looks like its clamped to the grid

mighty dagger
#

I changed floor to round and it's a bit better, but completely stopped collisions, debugging now

quiet ibex
#

@mighty dagger there's no reason your Actor class should own the AABB implementation. You could clean it up a lot by separating the intersection checks to a separate class

earnest wigeon
#

I've posted this in "shader-dev" but this channel seems to be also relevant.

I'm working on a cross-platform node-based material editor similar to my previous similar project (https://itch.io/queue/c/290843/urho3d-projects?game_id=273385 https://www.youtube.com/watch?v=DGMyL1ZK5WE ). The UrhoSharp engine seems to be dead so I'm working on generalization of the tech and making it configurable to various engine. I've already build the base of the new editor - a Spirv node-based shader viewer and about to start building the actual meat of the new one. The idea is to have a visual material and a tool to generate shaders for render passes for different platforms via spirv-cross, etc. Would you be interested in contributing to the project? Or, at least, do you see such project be useful to your project?

Please mention me in a reply so I can get notification.

hot hazel
#

please do not advertise in this channel

#

im sure someone will find it useful, though monogame nor (i assume) gdx support spirv

quiet ibex
#

@earnest wigeon where's the monogame integration? and why are you linking to an itch.io page when you want contributors? should've linked to github instead

earnest wigeon
#

@hot hazel the editor suppose to generate spirv that could be translated into HLSL, GLSL, MSL, etc. Game engine doesn't need vulkan support to use it.

hot hazel
#

meh, a lot of work for likely wasted effort

#

monogame uses a custom cross platform HLSL compiler

earnest wigeon
#

@quiet ibex there is no game engine integration at the moment as it's not even close to completion ๐Ÿ˜ฆ Itch.io proves that it is doable as I already did it for a different engine (Urho3D).

#

CobaltHex, so you sure a visual shader editor won't be useful for monogame?

hot hazel
#

not saying it wont be

#

just having it output to spirv not likely

#

unless you want to write a compiler for fx/mgfx

earnest wigeon
#

spirv-cross suppose to take care of it

#

it can output hlsl and then one can compile it into fx, I guess

#

fx is a compiled hlsl shader, am I right?

hot hazel
#

no

#

fx is a legacy hlsl format

#

mgfx is the monogame-specific compiled version of that

earnest wigeon
#

I see

hot hazel
#

fx is the effects framework, which may also give you trouble, (though basically just need to bundle things into passes, all stages go into a single file, few other changes)

#

basically a dx9 relic

earnest wigeon
#

I kinda remember it from old times but I was using OpenGL back then so I'm not very familiar with it.

quiet ibex
#

it'd need to be able to be limited to dx9 features on the output or its going to end up being unusable for monogame

earnest wigeon
#

is there a lowest shader model version to be supported?

#

dx9 is quite flexible on it

hot hazel
#

ragath i think monogame actually supports dx11

#

2.0 i think is the lowest i think gleb

#

i think you can compile 4.5 or 5.0 shaders too, but they may not work on ogl targets

quiet ibex
#

the tech supports it, but not the effect class

hot hazel
#

you can write your shaders in sm 5.0, just not use things like structured buffers/etc

toxic moat
#

Hi! ๐Ÿ–๐ŸŽฎ

hot hazel
#

hi

cyan brook
#

Hi! I am doing my first steps with Monogame, I have followed the Getting started tutorial from the official website and it's working ok, but I have a question: the code to prevent the ball from getting out of the window is on the "Update" method, so it is calculated at every loop, even when it does not really change (or not often). But couldn't find a way to move it to the "Initialize" method since the texture width/height is used to get the limits, and the texture is not set until the "LoadContent" method. And putting it there seems a little out of context. Any idea? ๐Ÿ™ƒ

hot hazel
#

put whatever check you want in the load content method

#

Initialize might come after load content im not sure, but it doesnt really matter imo

pearl ore
#

Initialize comes before LoadContent. But like Cobalt said, you can put the check in LoadContent. If you want it to make sense, just think of the method as "when the content is to be loaded". So: "when the content is to be loaded, load the texture, store it into a variable, and set the width/height limits based on the texture".

cyan brook
#

All right, thanks a lot!!!

limpid belfry
#

just migrating back to monogame for a bit of fun but, it appears to hate VS 2017

#

there's new things called NuGet packages? they never had this when I programmed in monogame ages ago, this thing won't install now cause

#

really i was going to go back to vs 2013 at this rate cause this is really crap

#

there's so much junk with monogame now

#

like i don't even understand what is going on here, I never saw this crap when i was coding in VS years ago

raw warren
#

NuGet packages allow you to import code

#

For example, I imported the AnimatedSprite class

#

Also, Iโ€™ve never once had that issue you pointed out in your last screenshot (I am also using VS 2017)

limpid belfry
#

yeah this is a fresh monogame install too

#

i simply am too small brain to figure out what's going on

#

"using directive is unnecessary"

#

it's auto generated

#

why is this thing such dumb

#

i'm pretty sure all my public key tokens are messed up

#

why would that be when this is a fresh install?

#

no idea

limpid belfry
#

well ok

#

now i'm getting some where

limpid belfry
limpid belfry
#

Right after all that fixes I now have this

#

I was useing the "MonoGame Windows 10 Universal Project" now I'm using the "MonoGame Cross Platform Desktop Project" because of this error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'SharpDX, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'. The system cannot find the file specified.'

It all looks like it works to me so i don't care it's only to mess around in now

quiet ibex
#

sadly monogame hasn't managed it's nuget dependencies well in the past, so might have to reference the correct sharpdx nugets manually

hot hazel
#

i recommend installing mongame on your machine

#

that will also give you the tools

quiet ibex
#

true, but its still better to have nuget dependencies

pearl ore
#

Now that I'm thinking about it I think I've had that problem as well, having to add SharpDX to Nuget for the DirectX project to build

#

Somehow I managed to get everything in Nuget. Someone added the pipeline tool for Mac and Windows, so now you can clone my project, restore Nuget packages and you'll be all set. We had to do it that way cause my partner was working on his University's computers at the time and they don't have admin access to install MonoGame

quiet ibex
#

now that they're adding support for .net core projects, it also opens up the possibility of creating a meta package that retroactively adds the nuget dependencies that monogame should've had in the first place

limpid belfry
#

oh nice

#

cause that was a nightmare

limpid belfry
#

Height based landscape maker

#

Exports to a 1024x1024 image, that will be used for height data, now, this will be able to generate land mass and have it kind of how dwarf fortress does it but I'm using this for a base landscape

#

I have to fix the performance issue with it which I have an idea for this

hot hazel
#

that is a painful blue

rain totem
#

it's definitely very bright

obtuse island
#

ok ok why is it called visual studio 2019 when its updated in 2020 ๐Ÿค” ๐Ÿค”

hot hazel
#

cuz they havent bothered to make a new proper release

#

if they plan to at all

quiet ibex
#

they've released every 2-3 years since the dawn of time pretty much. doubt it'll change now

pale eagle
#

Anyone able to help me with implementing movement to my cars in MonoGame?

pearl ore
#

!dontask

restive tapirBOT
vagrant basalt
#

Fair enough

lament gyro
#

Does anyone know a good solution for "reusing" the vertexbuffer of a SpritePatch?
What I wanna do, is let the SpriteBatch generate the vertex data for my tile map, so my cpu doesn't need calculate/upload it for every frame.

pearl ore
#

And then you can render it with BasicEffect. You'd need to set up a projection matrix, I usually just take the same one MonoGame's SpriteBatch class uses and then apply a transform matrix to it.

quiet ibex
#

yea you want a vertex buffer optimized for static usage

#

but you need to consider the layout in the buffer, so you aren't pushing all the off-screen vertices through the gpu in vain

lament gyro
#

thx for your answers, I was afraid ther isn't an "easy" solution.

#

the offscreen verts aren't really an issue imho. the cpu time of creating the verts is much more precious.

quiet ibex
#

it basically sets up screen-sized rows of vertices going in a vertical zig-zag pattern across the screen. that way the gpu knows the position of the first and last visible vertex in the buffer

lament gyro
#

my map is chunked (32x32 tiles), so I can decide wich chunk to render. checking for each vert or tile if it is in visible, might be more costly than beneficial. But I'll think about it.

quiet ibex
#

there's even faster ways of rendering huge tilemaps using a shader that samples 2 textures, but it runs into precision issues on some gpu's at certain mapsizes

#

the rendering takes so little time when using it, that you can see noticeable fps drops just by moving your mouse across the screen though

#

11k fps was the most i managed to crank out of it

lament gyro
#

11k is a litle more then I need. ๐Ÿ˜‰

#

my issue is, that my map is pretty dynamic (chunks get load/generated, tiles are animated and can be changed), so I have to balance speed and flexibility.

#

but I defenetly never need to do it more then 30-60 times a second.

quiet ibex
#

you want to avoid generating chunks during regular gameplay if you can help it. most procgen algorithms generate a fair bit of garbage

lament gyro
#

I have that part working, its on its own thread, so there are no bigger issue.

quiet ibex
#

i was doing a 2d zelda style game with generated levels, but i hid the generation when transitioning between dungeons and the overworld

#

the gc stalls all threads, not just the one doing the work

lament gyro
#

I know, it's a bit of a pain, but exceptable for my game. I'll try to optimize that, if it becomes a real issue.

hot hazel
lament gyro
#

sorry, im not that used to reading shader code. Does this get a texture with colors that represents the the tiles and it basicaly creates them with the right texture?

hot hazel
#

so theres two textures

#

one is your tilemap texture

#

the other is your tile layout in the form of a texture (basically upload your tilemap array as a texture)

#

then the shader, when rendering the map divides the texel position into tilemap squares

#

finds the right tile to draw from the tile layout texture and draws the corresponding pixels from the tilemap texture

#

(some math there, not too complicated)

lament gyro
#

could be an interesting approach... thx

hot hazel
#

it is 100000% more efficient

lament gyro
#

is there any benchmarking you have done? how many tiles are doable?

hot hazel
#

the beauty of doing it in a shader

#

it will always take the same amount of time regardless of the size

#

only factor is size of viewport (number of pixels rendered)

lament gyro
#

theres probaply the max texture size limit too

hot hazel
#

modern GPUs no

#

(not practically at least)

#

dx9 era was 2048x2048

#

and if you need you can always chunk it, but i doubt your map will be larger than like 2^32

lament gyro
#

for now I think the "classic" approach is easier to implement, but doing it that way sounds realy interesting...

hot hazel
#

meh, i would say this method is worth figuring out

lament gyro
#

the "issue" is, that my map is composed of more than one layer. that makes it a litle more complicated

#

and im not 100% convinced that this is "that" much faster, then just rerendering the vertex buffer.

#

for now, being flexible is major point.

hot hazel
#

so if you had a vertex buffer

lament gyro
#

but Ill defenetly tinker around with it

hot hazel
#

you quads for every tile

#

vs one quad

lament gyro
#

if I get 100+ fps on low end PCs with both methods, why should I care about more complicated one?

quiet ibex
#

it is much faster, the difference between rendering a vertex buffer and rendering a fullscreen dual-textured quad is huge

#

but there is a size limit you'll hit, not because of the size of the texture, but due to floating point errors in the math you're using in the pixel shader

lament gyro
#

I'd guess odd transforms are a big issue?

hot hazel
#

meh

#

i wouldnt say odd

#

but you're gonna run into floating point issues in any thing involving the gpu likely

#

(if your numbers get big)

#

anyway for me tilemap rendering traditionally was fine until i wanted to also render a large map with all of my other stuff as well (and running gameplay code, etc)

#

it was low hanging fruit

lament gyro
#

just a small update for you guys: my benchmark scenario is 707458 Quads rendered. with the normal sprite batch i get ~12.5 fps, with the reuse of the vertex buffer ~100 fps. Im really happy with it.

reef light
#

nice!

pastel spade
#

I'm making a purely 2D fighting game using LiteNetLib for networking. I am loading sprites in from textures. Do any of you know if there are any benefits from using monogame over Unity? I'm thinking executable size, platform compatability, performance etc.

lament gyro
#

why do you care about executable size?

dapper monolith
#

The biggest factor that always makes me use MonoGame over Unity is having more control over everything. I always feel like Unity gets in the way of how I want to do certain things.

reef light
#

that is a loaded question that will spark debate.

#

you can make wonderful stuff in MG

#

i tend to push unity when you are doing something heavy in 3D

#

but champion MG for everything else

scarlet glacier
#

weird question: does Nez support rendering to a texture? I still want to use Nez's rendering stuff but I want to have a fixed resolution regardless of window size

#

is it a bad idea to override Draw()?

reef light
#

just depends on why you are overriding it

sweet tinsel
#

Hey all I need help with a math problem. I have a 3d rocket that's rotated to look straight ahead. I want the camera to follow the rocket. The mouse should turn the rocket, however, the rocket should always be moving straight. I'm using LibGDX for this and I haven't received any meaningful help in their discord

prime sigil
#

Does anyone know how I can draw a filled-in circle in Monogame, the same way I can easily draw a rectangle with the spriteBatch.Draw()?

hot hazel
#

a few methods, but all will involve a shader

prime sigil
#

How do I involve shaders?

hot hazel
#

either draw geometry yourself (quads here, so a 4 element vertex buffer) or spritebatch.Draw, both with a custom effect

#

but you can easily create a shader to draw a circle in a quad (simple polar math), or you can use an SDF shader, which may not look quite as good, but lets you draw several shapes with that

prime sigil
#

I see

#

What's a buffer?

#

Vertex buffer*

#

Compared to a normal vertex

#

And since it's a shader, I need to add an "Effect" right?

pearl ore
#

This extends SpriteBatch for primitives (rectangles, circles, etc.). I wouldn't say it's the most performant thing in the world but it's most likely adequate.

#

What Cobalt suggested would be much better, but I use this as a quick n dirty way of drawing circles (and other primitives).

prime sigil
#

I see, thanks!

#

Quick question though, do I just copy the Primitives2D.cs file into my project to make use of it?

pearl ore
#

Yep

strange tendon
#

I'm working on a fork of MonoGame. Is there a resource that explains what the different .sln and .csproj are meant to encapsulate?

hot hazel
#

such as?

#

@prime sigil a buffer is a collection of something (like an array/list). so a vertex buffer stores your vertices (on the GPU)

#

shaders = effects in monogame

prime sigil
#

Shaders being Effects in monogame explains a lot

#

Curious what the difference is between these two

#

When creating a new .fx

prime sigil
#

Why do shaders/effects only work when the SpriteSortMode is set to Immediate? (SpriteSortMode.Immediate)
Is there no way to have effects work when it's set to Back to Front, for keeping the layers of my sprites intact?

hot hazel
#

they dont

#

how are you applying your shader?

prime sigil
#

Like that

#

I'm using this tutorial

#

But it doesn't 100% work, I get different result sometimes

hot hazel
#

yeah you need to use spriteBatch.Begin(..., effect)

prime sigil
#

I see, will play around with it more, thanks

#

Yep, it works!

#

Another thing though, do you know why my sprite doesn't show pure red despite using float4(1,0,0,1) for the whole texture?

hot hazel
#

thats a multiplying factor

#

so if your color is 1,1,1,1 its gonna be 1,0,0,1, but if its 0.5, 1, 1, 1 its gonna be 0.5,0,0,1

prime sigil
#

What's strange is that every pixel in my ship sprite seems to be 1,1,1,1
For example, when I try to do grayscaling:

color.gb = color.r

It's as if nothing was applied to it

prime sigil
#

Nvm! I think I fixed it

#

The output by the default .fx template was: return tex2D(SpriteTextureSampler, coords) * color
but I changed it to: return color
And it works now

fleet cosmos
#

Hey guys! Does anybody here is using Monogame 3.8 packages from nugget? i was able to create a project, as well as build it, with no issues... But, my problem is with the Content Pipeline Tool. I've installed it trough nugget as well, and can open it with no problems. But it does not build SpriteFonts at all, complaining about FreeType6.dll missing. I've done some search, and found some people saying to install VC++ Redistributable, and i did, but no success at all. Anybody managed to get it working?

#

btw, i'm sorry if this is not the correct place to ask. First time poster here. ๐Ÿ™‚

hot hazel
#

freetype is its own library

#

you can probably just google search for the dll

#

or find freetype's website

fleet cosmos
#

Hey @hot hazel, thanks for the reply. I've got the dll, and even inside the tools folder on monogame pipeline it's there, still, the pipeline seems to not be able to find it... I'll keep trying here, since, because of a weird texture bug on my graphics driver, monogame 3.7 is not that good for me, while 3.8 is...

restive tapirBOT
#

TheLorencini gave karma to CobaltHex

hot hazel
#

copy it to the directory where your executable is

fleet cosmos
#

copy it to the directory where your executable is
@hot hazel it's there already...

#

even copied it to system32

#

very weird...

#

on 3.7, at least i could use the pipeline tool, but had the texture bug on the lib itself.

#

i guess i'll have to do some weird merge of the two (using 3.7 pipeline tool, and 3.8 dll filed)...

#

let's see

#

after all, 3.8 is not stable yet... can be some bug.

hot hazel
#

personally i use my own sprite font tools

fleet cosmos
#

personally i use my own sprite font tools
@hot hazel read some things about that, but never got the time to actually try it... Bitmap fonts seems to be a good way to go, since no matter the font i use, ttf fonts tend to be kinda blurried on my projects...

hot hazel
#

well id say use bitmap fonts

#

but roll your own solution

pearl ore
#

I think you need to install the 2012 .NET Visual C++ redistributable IIRC to fix the freetype6 DLL not being found.

hot hazel
#

why would you need the 2k12 .net redist

fleet cosmos
#

I think you need to install the 2012 .NET redistributable IIRC to fix the freetype6 DLL not being found.
@pearl ore .NET? I've read that the one that fixes this is the VSC++ 2012 redistributable... Even now, that i'm back on 3.7, i've had to install it.

pearl ore
#

Yeah you are correct, I wrote that with half my brain working. My fault.

stoic crown
#

does anyone here uses Ogmo editor 3.0?

#

I'm having problems, for some reason I can't save changes made to the project (like adding a new entity)

#

I didn't know where to ask for help so I'm trying here

hot hazel
#

#misc-dev or any official communication locations would be better