#monogame-and-libgdx-dev

3045 messages · Page 1 of 4

hot hazel

usually this stuff also works with the rest of your game, so its part of an engine

copper vector

I'm trying to draw my player at an angle, but whenever I do this it shows up as a black box
I've looked up and down but nothing seems to work

hot hazel

we're going to need more detail than that

copper vector

I ended up fixing it, it was the content pipeline on monogame just not updating for some reason

atomic thistle

hey so i'm trying to make my game window maximize itself upon launching using system.windows.forms and its control.fromhandle method, but for some reason that method isn't working and it's only returning null

how can i fix this?

(this is monogame btw i have no idea what lib gdx is ^^")

hot hazel

i believe the window does not exist yet

add an event to graphics.DeviceCreated

check there

atomic thistle

well that's the thing, it does it no matter where i grab it at, even during runtime

like in the update method somehow

i have the same setup in another project and it seems to work fine

but uh yeah i tried that and it does seem that the graphics device is created

:D
what

hot hazel

if you put a breakpoint

what is window.Handle

atomic thistle

a bunch of hexadecimal stuff that i don't understand

hot hazel

im going to guess there is not an associated windows form

try

add [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); to your main cs file

in the class

atomic thistle

wait where? that's some weird lookin code

hot hazel

and then somewhere in the code ShowWindow(Window.Handle, 3)

just at the top of whatever class this code is in

atomic thistle

oh it's erroring me, saying that dllimport, marshalas, and unmanagedtype couldn't be found

hot hazel

add using System.Runtime.InteropServices; to the top

atomic thistle

okay did that, what's supposed to happen?

hot hazel

(this only works on windows)

atomic thistle

oh, if it helps at all, i did set this project as cross-platform opengl

hot hazel

if its running on windows this will work

linux/osx use their own mechanisms for maximizing a window

(you can probably find a cross platform library that takes that window handle, if its an issue)

atomic thistle

oh

well

that method's still not maximizing it

but it's not erroring

hot hazel

store the return value in a variable

whats it returning

also try calling it in different places

see if it makes a diff

atomic thistle

false

hot hazel

try putting it somewhere later in the code then

atomic thistle

nope, always false

hot hazel

not sure what to say then

is your window fixed size?

atomic thistle

not exactly

i have this event method for checking if the window size has changed and then setting the aspect ratio accordingly

        protected void ClientSizeChanged(object sender, System.EventArgs e)
        {
            Window.ClientSizeChanged -= ClientSizeChanged;
            if (Window.ClientBounds.Width > 2 * Window.ClientBounds.Height)
            {
                graphics.PreferredBackBufferWidth = 2 * Window.ClientBounds.Height;
            }
            else if (Window.ClientBounds.Width < (4.0 / 3.0) * Window.ClientBounds.Height)
            {
                graphics.PreferredBackBufferWidth = (int)((4.0 / 3.0) * Window.ClientBounds.Height);
            }
            graphics.ApplyChanges();
            Window.ClientSizeChanged += ClientSizeChanged;
        }
hot hazel

Window.AllowUserResizing

is that set to true

atomic thistle

yeah

hot hazel

not sure then

atomic thistle

the only think i can think of is the platform setting, since this one's cross-platform and that other one was windows only and it worked on that

hot hazel

ShowWindow should be able to maximize it whenever called

though i guess it might not work

because the windowHandle you're getting is not the actual window

but some intermediate representation

like opentk/whatever

atomic thistle

wait that actually helps a ton

i just need to figure out how to get the actual window then, right?

hot hazel

in theory

you may wish to browse the monogame source some

figure out what that handle is

atomic thistle

alright i'll do that tomorrow then, it's almost 2:30 am lol

thanks for the help @hot hazel!

restive tapirBOT

Axonium gave karma to CobaltHex

atomic thistle

man this feels really weird asking a question twice in a row after coming from the way more active #unity-dev, but how can i implement parallax scrolling for my background (i.e. making it move at a different speed)? i have my own method for making it wrap indefinitely, as for some reason the linear wrap samplerstate isn't working for me:

protected void DrawBackground(Texture2D sprite, SpriteBatch batch)
{
    for (int i = -1; i < 2; i++)
    {
        for (int j = -1; j < 2; j++)
        {
            batch.Draw
            (
                sprite,
                new Rectangle
                (
                    (int)((Math.Round(cameraX / 1920) + i) * 1920),
                    (int)((Math.Round(cameraY / 1080) + j) * 1080),
                    1920,
                    1080
                ),
                Color.White
            );
        }
    }
}

some notes on that: cameraX and cameraY are always negative (the opposite of what they are visually) for some reason, and the viewport resolution is technically always 1920x1080 due to the spritebatch using the "cameraMatrix" variable in this code block:

float scaleX = (float)Window.ClientBounds.Width / 1920;
float scaleY = (float)Window.ClientBounds.Height / 1080;
Matrix scaleMatrix = Matrix.CreateScale(scaleX, scaleY, 1.0f);
float xDif = cameraX - (ships[playerIndex].Position.X - 960);
float yDif = cameraY - (ships[playerIndex].Position.Y - 540);
cameraX -= 0.1f * xDif;
cameraY -= 0.1f * yDif;
Matrix translationMatrix = Matrix.CreateTranslation(-cameraX * scaleX, -cameraY * scaleY, 0);
cameraMatrix = scaleMatrix * translationMatrix;

so i really can't seem to wrap my head around how to use something like a "parallaxSpeed" parameter in that drawbackground method

hot hazel

there is a lot of hard coding happening here

anyway if you have a map position

parallax position = mapPosition * 0.5

you should not hard code window size into your game

at least anywhere past where its set

atomic thistle

window size can still be whatever you want within reason, but it's going to be a 1920x1080 one scaled down (or up) to keep it consistent

like if you set the window size maximized on a 4k monitor or something, it wouldn't be balanced to zoom the camera out because of that

anyways, what does mapPosition mean?

atomic thistle

(update to my question: made a change to the drawbackground method to make it much more readable; instead of calling 9 instances of batch.draw individually, it just uses two for loops now)

atomic thistle

(even more updatez to help with anyone that wants to answer: reworked all doubles to instead use floats to keep things consistent, changed player pos to a vector2, and made the camera pos no longer the opposite of what it should be)

hot hazel

why are you drawing it 9 times?

can i get a screenshot of what this looks like?

atomic thistle

well it's a bit too big to fit onscreen so you'll have to excuse my shoddy mspaint visualization

but it's a grid so that it can loop forever seamlessly, i know that i can minimize it to a smaller number (1 to 4 depending on how many should be onscreen) but i'm not really trying to go through the mental gymnastics of calculating that right now

hot hazel

what are you drawing in that pattern?

atomic thistle

the sprite

for the background i mean

hot hazel

yes i konw

what does it actually look like

atomic thistle

i mean it's just a generic star background i got off the internet, dunno why that's important at all

hot hazel

just trying to visualize what you're doing

atomic thistle

here; notice how the stars (most visibly the large ones) wrap to the other side of the screen once they go offscreen

hot hazel

you can much more easily do this by using a wrapping texture

atomic thistle

😀

i said specifically that that wasn't working with my scaling method for whatever reason :/

if i set it then the background just doesn't show up

hot hazel

render the texture at 2x the size of your window

then draw it at -(playerPosition % windowSize)

multiply those numbers by your scale

(you can do this via a matrix)

your scale may be wrong

atomic thistle

well it wasn't even showing up last i tried that so maybe it was the position as well?

either way i don't know what these variables mean, i'm not using the player's position but the camera's position and i'm not sure if windowsize refers to 1920x1080 or the actual size

and the camera position isn't the opposite of what it should be anymore so i don't know about that negative

hot hazel

player position = camera position

yes

window size is whatever the viewport size is

so GraphicsDevice.Viewport.Width/Height

atomic thistle

okay, so i feel like i'm almost there? just don't really know how to multiply the rectangle by the matrix i'm using

spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap);
spriteBatch.Draw(assets.GetSprite("stars"), new Rectangle((int)-(cameraX % GraphicsDevice.Viewport.Width), (int)-(cameraY % GraphicsDevice.Viewport.Height), GraphicsDevice.Viewport.Width * 2, GraphicsDevice.Viewport.Height * 2), Color.White);
spriteBatch.End();

(side note, assets is just a class i made with dictionaries and methods to grab a sprite or sound effect by its filename)

okay yeah i have no idea what i'm doing 😀

i really do not like having to work with rendering without using that matrix as the transformmatrix of the batch itself

but i know for a fact that the modulo operator is definitely what i should've been doing

hot hazel

i would start by getting it working without scaling/matrices

start simple

atomic thistle

okay back for another day of this, i really think that this is overthinking it

i don't want to have to rework my entire system and i really shouldn't because this is not what i'm trying to do

i had a method that worked the way i like and i just want to be able to use parallax speed with it

not sampler states, not messing with what the viewport size actually is, none of that

i'm sticking with this

protected void DrawBackground(Texture2D sprite, SpriteBatch batch, float parallaxSpeed = 1)
{
    for (int i = -1; i < 2; i++)
    {
        for (int j = -1; j < 2; j++)
        {
            Rectangle rect = new Rectangle
            (
                (int)((Math.Round(cameraX / 1920) + i) * 1920),
                (int)((Math.Round(cameraY / 1080) + j) * 1080),
                1920,
                1080
            );
            if (!Rectangle.Intersect(rect, new Rectangle((int)cameraX, (int)cameraY, 1920, 1080)).IsEmpty)
            {
                batch.Draw(sprite, rect, Color.White);
            }
        }
    }
}

that's final. i just want to know where to throw that parallaxspeed parameter into that rectangle constructor

even then, it's not drawing 9 times anymore, only up to 4 because i remembered that rectangle.intersect is a thing

as a metaphor, i shouldn't have to replace my whole car just because i want a better radio

hot hazel

yeah but if your car is held together with sticks and glue...

🙂

atomic thistle

ouch :/

guess i'm just lookin' somewhere else for help then

hot hazel

lol

im just joking

btw you can use rect.Intersects(new Rectangle(...)) rather than rectangle.intersect().isempty

atomic thistle

oh, i knew that existed but i tried doing it from the static rectangle class like rectangle.intersect() so it wasn't showing up

atomic thistle

okay, progress!

i ended up doing

double normalX = (Math.Round(camera.Position.X / camera.Resolution.X) + i) * camera.Resolution.X;
double normalY = (Math.Round(camera.Position.Y / camera.Resolution.Y) + j) * camera.Resolution.Y;
double offsetX = parallaxSpeed * camera.Position.X;
double offsetY = parallaxSpeed * camera.Position.Y;
Rectangle rect = new Rectangle
(
    (int)(normalX - offsetX),
    (int)(normalY - offsetY),
    (int)camera.Resolution.X,
    (int)camera.Resolution.Y
);

thing is though, it doesn't extend forever if parallaxspeed isn't 0

(as evident through where it cuts off at its top in that video)

atomic thistle
double offsetX = (camera.Position.X * parallaxSpeed) % camera.Resolution.X;
double offsetY = (camera.Position.Y * parallaxSpeed) % camera.Resolution.Y;
if (offsetX < -camera.Resolution.X / 2)
{
    offsetX += camera.Resolution.X;
}
else if (offsetX > camera.Resolution.X / 2)
{
    offsetX -= camera.Resolution.X;
}
if (offsetY < -camera.Resolution.Y / 2)
{
    offsetY += camera.Resolution.Y;
}
else if (offsetY > camera.Resolution.Y / 2)
{
    offsetY -= camera.Resolution.Y;
}
sturdy prairie

is there an easier way to apply AA in monogame than getting an AA shader and applying to a rendertarget?

atomic thistle
sturdy prairie

I tried this solution but unfortunately it isn't doing anything

for my project

atomic thistle

ah, don't know what to tell you then :/ it does seem like using shaders isn't the recommended way of doing it though

do you have any idea why that solution's not working?

sturdy prairie

not really

I'm fairly certain it's working

like

the code is running

but it's just not doing anything

atomic thistle

what platform are you building for?

sturdy prairie

windows atm

I think it's uh

opengl

atomic thistle

oh

yeah opengl kinda tends to break everything in my experience

would it be possible at all for you to move your code and assets to a project on another windows option? such as the directx one

since there doesn't seem to be any real easy way of converting an existing project to another option

quiet ibex

@sturdy prairie you're likely turning AA on and not applying the changes to the gfx device

if you do it in the Game1 constructor, you can be sure that it takes effect

sturdy prairie

I'm doing it in the game constructor yes

pearl ore

I ended up using FXAA. It's decent enough.

manic granite

Hello, im Using Monogmae w/ Xamarin & im trying to get this tutorial working for Android:
https://www.youtube.com/watch?v=CcPb0bKkpeg&list=PLHJE4y54mpC5hrlDv8yFHPfrSNhqFoA0h&index=2
The thing is when im trying to load the image I get an error of not finding it

 public class SplashScreen : GameScreen
    {
        Texture2D image;
        string path;  
public override void LoadContent()
        {
            base.LoadContent();
            path = "WowperroFirmaWhite.xnb";
            image = content.Load<Texture2D>(path);
            if (image == null)
            {
                image = content.Load<Texture2D>("WowperroFirmaWhite.png");
            }
        }

In other part of the code I also have

 public class GameScreen
    {
        protected ContentManager content;
        public virtual void LoadContent()
        {
            content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Assets");
        }

How do u know which path to use w/ Xamarin

Pls help I´ve been stuck here for a while unu

manic granite

please @me if you read this & know the answer

reef light

your path is wrong

manic granite

Ok, but I have a question, does the path acts the same if using Xamarin?

reef light

i dont know xamarin, but if you are getting a path not found, i would start there

manic granite

with c# can u create a .txt file like w/ c++ to know where the program is searching?

like without specifieng a path

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}

like this but w/ c#

reef light

it's all reference, you gotta start from somewhere, just hardcode the path and see if it gets past the error, if it does, then work our how your file references will be, if it doesnt then you got other issues

in C# look up FSO

quiet ibex

@manic granite System.IO.File.AppendText("example.txt", "Writing this to a file.\n");

or something like that

hot hazel

or System.IO.File.OpenWrite/new FileStream(...) -> stream.WriteBytes/whatever

or even new StreamWriter(file) -> writetext/whatever

plenty of options

manic granite

Thx for all the assist, In the end I did not know what was happening, but it said acces denied, But i have fixed the path problem, thx

split warren

can anyone suggest how I can implement multiple scissors in libgdx, I am trying a window like feature where the character is only visible inside the window and is clipped outside

hot hazel

change the scissor rect per call. or use a different method

like depth/z buffer

or alpha testing

or good old math

reef light

^ this, alot of different ways to approach it

split warren

thanks @hot hazel , i tried depth clipping, it worked

restive tapirBOT

kamlesh457 gave karma to CobaltHex

hidden shell

Hey, I know this is opinion-based but what aspect ratio should I design my game under?
What I'm making is not much of a game, and more like a typical app.
I have a single background image that should be shown on any aspect ratio without black bars.

Looking at StackOverflow, answers seem to lead to designing for 16:9 (most common aspect ratio for android phones).
Therefore I downloaded a 1920x1080 background image.

Since I don't want black bars, using FitViewport is out of the question.
I decided to use either ExtendViewport or FillViewport. Testing both, FillViewport seemed to be the better result.
ExtendViewport still had a bar when running on a different aspect ratio than designed.
FillViewport didn't have black bars at all, but it still had one issue.

Running the app on a 16:9 screen showed the image perfectly (as expected). However, running it on a screen that's wider, such as a 1800x2560 tablet, results in the picture being extremely zoomed in (also a bit expected considering that's what FillViewport does).

Instead of trying to get assets for 16:9, should I find a background that would fit wider resolutions so that it doesn't look extremely zoomed in? I can't figure out how to scale to different aspect ratios properly even though Viewports should be making it easy for me.

jagged slate

Shoot for an actual target device. If it's PC, yeah stick with 16:9. Lots of android and ios devices have 16:9 or 16:10. Switch is 16x9.

Just for some examples

hidden shell

@jagged slate ok thanks! what viewports do you tend to use? would extendviewport be best for game objects, and fitviewport for the user interface?

stackoverflow answers tend to lead to fitviewport the most but i really don't want black bars if possible

restive tapirBOT

winter is coming gave karma to Kipling

reef light

indeed, it's all driven by device

most PC games allow the user to choose all supported or a large set of available card/gfx drive resolutions and color depths

hidden shell

if i want to support a set of aspect ratios without black bars, will i need to have a set of assets for each of those aspect ratios?
e.g. a wider/shorter background for 4:3 and a thinner/taller background for 16:9?

for now i'm just going to design it for 16:9 but even with viewports it still feels off

reef light

depends on your D

alot of games, just rescale

i theory, people only play in a certain aspect ratio at different sizes, so in theory, you 2d resources dont scale, but your background layers and such, should show more

also, there is no rule, that says, you have to support multiple

hidden shell

i just read about mipmaping so i'll just be using that instead of having to manually resize images for different resolutions. i'm definitely gonna have to find a bigger background that can show more if a wider screen is used
thanks @reef light!

restive tapirBOT

winter is coming gave karma to TormentedGothicPrincess

reef light

i wouldnt provide different resource sizes, use code to ratio up or down

major of games will only provide 1 (hires) or 2 (high/lowres) textures/resources

jagged slate

TGP's experience is similar to my own. Also I've heard of doing some cool things with having device info pulled on download and then pulling down textures of specific sizes afterward to match so you don't have to resize

honest fjord

some 3d libgdx

the shadows stuff is really tucked away

manic granite

Yo, i´m tring to download an apk to my phone (Xiaomi Redmi 6) the apk is generated w/ monogame in visual S 2019, i have the xamarin emulator & i can make it run on it, but when I pass the apk to my phone I get this error java.lang.exception: Unable to get provider Any ideas?
Here is my manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="testandroid.testandroid" android:versionCode="1" android:versionName="1.0">
    <uses-sdk />
    <application android:label="testandroid"></application>
</manifest>

And here is the error

java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_27!
    at android.app.ActivityThread.installProvider(ActivityThread.java:6407)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5909)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5826)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1708)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:6662)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_27!
    at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6395)
    ... 10 more
Caused by: android.content.pm.PackageManager$NameNotFoundException: Mono.Android.Platform.ApiLevel_27
    at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:381)
    at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:363)
    at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:35)
    ... 11 more
split warren

Disable Use Shared Runtime from Project ->Options->Android Options.

reef light
manic granite

Thx a lot guys, the first option worked for me

now im stuck w/ screen size, 😦

Anyone that knows hoe to get the screen size, cause when I build, & pass it to my phone, it does not look good

 public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
    {
        public static int ScreenHeight;
        public static int ScreenWidth;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            var g = new Game1();
            SetContentView((View)g.Services.GetService(typeof(View)));

            ScreenHeight = (int)(Resources.DisplayMetrics.HeightPixels); // Resources.DisplayMetrics.Density);
            ScreenWidth = (int)(Resources.DisplayMetrics.WidthPixels); // Resources.DisplayMetrics.Density);

            g.Run();
        }
    }

ScreenH & ScreenW
It works /w Xamarin VS & Monogame
Srry dont´know

quiet ibex

@manic granite you shouldn't set resolution when building for android

manic granite

Then, where should I get resolution?

quiet ibex

@manic granite you can get the backbuffer size from the graphicsdevice

reef light

@manic granite you can use

[Game.GraphicsDevice.Viewport]
your stuff will be [ClientBounds] and you can get the availables from [GraphicsAdapter.SupportedDisplayModes]
hot hazel

if you wnat the actual window size. GameWindow.ClientBounds

if you want the size that your game will render to, backBuffer width/height

viewport by default will match that size, but not required to

frozen portal

anyone gradle pros know whats happening here?

frozen portal

better screenshot

hot hazel

this is not the channel to ask this

frozen portal

I'm just trying to run the basic libGDX application in HTML the way you're supposed to

so if anyone has a libgdx game that works in HTML, could you help me out to figure out why yours is working..?

(this is while trying to run superdev btw)

frozen portal

I got a bit further

Is it supposed to look like this? It doesnt look like my game at all...

pearl ore

It's supposed to be loading in your assets. After it's done loading it will start running your game.

manic granite

It was with the viewport, thx for all the help,

verbal fox

For libgdx, I get some weird error saying something about a bad version 57?

When I'm trying to use their builder .jar file

Anyone know what that is about?

pearl ore

Make sure you have the latest JDK installed and that it's in your path. Usually an error like that is that your environment Java version is lower than the version of LibGDX's builder.

verbal fox

hmm now for whatever reason I get an invalid package name error

yeah I still get General error during semantic analysis: Unsupported class file major version 57

java --version

java 13.0.1 2019-10-15
Java(TM) SE Runtime Environment (build 13.0.1+9)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)

Seems like libgdx doesn't work with java 13

Feel like that should be a huge disclaimer on their site

pearl ore

Strange, Java is meant to not have breaking changes like that. If it worked on a lower level of Java it should run on a higher version no problem.

verbal fox

Real shame, I wanted to give it a try, but can't even install it

Google doesn't even return anything

pearl ore

Are you double-clicking it or are you running it through the command line?

verbal fox

Oh it looks like Gradle itself fails to build, so dumb

pearl ore

Yeah that's the only thing I found but I didn't know if that's the issue you were having

verbal fox

I guess the pointed question is: How do I tell the LibGDX setup jar file to use gradle 6.0

Seems like it doesn't use system level gradle, cool.

pearl ore

I wonder if when you click Generate if it puts the files in the destination folder

And just run gradle yourself

verbal fox

It does indeed, I tried to fiddle around with the project but I can't upgrade gradlew

pearl ore

Yeah, I'd just delete gradlew and see if it'll build with your installed Gradle. Although from version 5 to 6 there might be breaking changes who knows

Might have to grab a different lower version of gradle.

verbal fox

I have gradle 6.0 available

pearl ore

Or, just install an older JDK lol

verbal fox

Do you know the older version number?

pearl ore

Eh, now that I'm thinking about it it probably won't work

Cause at the end of the day you still have JDK 13

verbal fox

Damn, well RIP libgdx

pearl ore

Try Gradle 6 first, no harm in trying since it's already installed

verbal fox

i tried gradle desktop:run but says that command wasn't found

pearl ore

Try just gradle

The generator runs gradle, don't know what task but it downloads a bunch of dependencies. It might need that to get the desktop:run to work, but I'm not sure. Never had this trouble of course.

verbal fox

wow it worked

frozen portal

Hello! Is it possible to compile a LibGDX game for HTML with the Socket.io module?

frozen portal
pearl ore
frozen portal

Is GWT similar to Socket @pearl ore?

Would I have to make notable changes to my code base? (converting certain data types to bytes isn't notable)

pearl ore

GWT stands for Google Web Tookit. Basically, it's a compile target for Java (turns Java into JavaScript). This is how LibGDX is able to run as an HTML app, it essentially transpiles your code into JavaScript. Since it's turning Java into JavaScript anyway, you can use JavaScript code if you wrap it. That means that you can use any JavaScript library, including socket.io. It involves a little work, you have to create a Java wrapper around your JavaScript code.

frozen portal

So I would have to make a Java class that wraps the JS Socket.io library and make method calls to that instead?

If that's the case I'm not sure how to go about doing that.

pearl ore

The documentation I linked explains the basic process, it's just a matter of reading and figuring it out. There's also a couple Google I/O presentations that are pretty helpful.

Or you can see if you're lucky and see if someone has already made one for socket.io.

frozen portal

just as I'm reading, couple questions

  1. I need to install JSNI (as a module/library), right?
  1. Is my goal to turn all the Socket.IO classes into JavaScriptObjects?
frozen portal

@pearl ore

frozen portal

I finished reading, from what I understand I must

  1. Find the JS version of the socket.IO library (currently, I have the Java version)
  2. For the classes I want to use (Socket, IO and Emitter), I have to make a Java class that extends JavaScriptObject so I can communicate with them
  3. In my code, replace the socket.IO native classes references with my new Java classes

What I don't understand is step 2 (sorry for the pinging @pearl ore do tell if I'm being annoying)

Wait, is it just as simple as doing this for every class and putting in the correct namespace?

pearl ore

Seems so. Personally, I'd wrap around socket.io with my own interface in JavaScript and then use that to talk between Java <--> JavaScript. That way you don't have to wrap around the whole socket.io library, just an interface with parts you'll use.

frozen portal

Something like this?

Game: instantiates and calls methods to javascript classes
Javascript Classes: implements the interface and calls the socket.io methods
Interface: defines the socket.io methods to inherit

Have I got this right @pearl ore

im not fully certain this makes sense

One thing I don't understand is what html:dist is going to do. The only way to call socket.io methods from any language would be to compile the module, and when I tried it fail. If I compile the Javascript version of the module, GWT will notice it's JS and not try to transform it to Java code? because from what I understand that's what it doesn't manage to do. Do I understand the problem correctly?

Side Question: is there a library similar to Socket that works with GWT?

also could I just use that? i dont have time to test it but would it solve my problems?

pearl ore

Seems right to me. It's been a long time since I've used GWT, I can't recall off the top of my head how to the JavaScript to interface directly. When you run html:dist it's going to compile your game in Java to JavaScript using GWT. There's a configuration file in the 'html' module that you have to configure at the very least. LibGDX has good documentation, and GWT has been around for a while so it'll just take some hard searching to find what needs configured.

As far as using another library, there's the one you listed. Depends on if you absolutely need socket.io or not. There are also ones for websockets instead.

frozen portal

@pearl ore I've heard people say that if I want to do this and have the game run in the browser, I CATEGORICALLY need to use websockets

I hope that's not true

I made some progress trying to make the GWT_Socket.io compile correctly but boy importing modules correct isn't easy

pearl ore

socket.io is a wrapper around websockets nowadays. There is RTC but I'm not sure if that took off or not.

frozen portal

@pearl ore man this was a slow day for me... Am I supposed to implement the JS Socket.io code as a library or as a module in my project's core?

pearl ore

Oh, well in your core you can define an interface and pass it as a parameter to your main game class. Each platform you have to supply an implementation of the interface. In your html project you can implement it using JavaScript.

frozen portal

okay so for the part that I understand, aka the Java distribution of Socket.IO

The non-HTML implementation of the interface that abstracts away for me all needs of instantiating Socket.IO classes like Socket or Emitter instead has its own methods that the core code will call (and IT instantiates those objects)

so for instance I could turn the code

data.put("x", player.getX());
data.put("y", player.getY());
data.put("rot", player.getRotation());
socket.emit("playerInit", data);

into

SocketIO socketInterface = new SocketIO(whatever is needed here);

[...]

socketInterface.emit("playerInit", {"x", player.getX()}, {"y", player.getY()}, {"rot", player.getRotation()});

and in the socketIO implementation for non-HTML it would look like

public void emit(String event, Object[] ... args){
    JSONObject data = new JSONObject();
    for(Object object : args){
        data.put(object[0], object[1]);
    } socket.emit(event, data);
}

(JSONObject is also something GWT had trouble compiling so that's why I abstract it away)

So far am I correct @pearl ore ?

pearl ore

Little hard to read so here's a little pseudocode to illustrate (might be what you had in mind idk):
core:

interface INetInterface {
    void sendEvent(string event);
}
...
INetInterface netInterface = ...; // Some implementation supplied by the `html` module
netInterface.sendEvent("foo");

html:

class HTMLNetInterfaceImpl implements INetInterface {
    public void sendEvent(string event) {
        js_sendEvent(event);
    }
    private static native void js_sendEvent(string event) /*-{
        // Regular-old JS here to call socket.io directly
        socket.emit(event, {});
    }-*/;
}
frozen portal

Okay, I do believe that's what I'm doing!

pearl ore

👍

frozen portal

Almost done with the GWT-friendly implementation

I'll get back to you if I have trouble with the non-GWT implementation

also
/*-{ }-*/
I discovered this notation today and... it's not a comment? meeseeks_surprised

pearl ore

It is

It's just that the GWT compiler specifically is looking for it and will recognize that you want the contents to be treated as JavaScript

frozen portal

Woow

That's amazing

Holy shit I might actually be able to do this

pearl ore

Some project, can't remember the name, lets you do the same thing with C++ which is neat. Creating native wrappers can be a pain sometimes.

frozen portal

Currently going over the part of my code that set all the Socket.IO callbacks

looking good?

after the etc comment is the old code

pearl ore

Eh, hard to tell without context

Like what socketInterface is, for example

frozen portal

The interface of socket IO

which in this case is a "GWTSocketInterface"

pearl ore

Oh okay. Yeah, seems fine. Keep in mind potential threading issues since you're using Runnable, I've slapped myself in the face over that more than once

frozen portal

I'm somewhat scared about that :/

Though a LOT of the old code upon receiving data would go to a runnable anyways since if I didnt I would get the error that stuff is getting instantiated without being in a "gdx context"

so it should be fine..?

pearl ore

Yeah it's fine, just something to keep in the back of your head.

frozen portal

yep

also I have to make a custom type of runnable since normal runnables dont take in parameter data and these need to

am i right or would that be a big no-no

(Just discovered "lambda expression" and wow! they look cool)

pearl ore

Yep, that lol

frozen portal

(i hope there's no risk using em)

What do you mean

pearl ore

The run method intentionally doesn't have parameters, because it's starting a different thread. It doesn't make sense. But you do want data in that thread, so you'd extend Runnable with parameters in the constructor and make them member variables.

sudden dome

Runnables don't start threads, though

pearl ore

00f

Yes you are correct

Threads start runnables

🤦‍♂️

thx

sudden dome

you can look at Consumer for a type that brings in a parameter and doesn't return anything

frozen portal

Is this fine..?

sudden dome

you lose a lot of type definition by it being varargs of just type Object

frozen portal

but it could be anything, right

is there a better way to do it?

sudden dome

Maybe -- I'm not the best to jump in on that part of the conversation. If you can define your data with some structure -- say a parent class / base type -- that might help

frozen portal

I have to rethink this anyways since if I were to continue I'd run into problems

specifically JSON objects not being gwt-friendly

sudden dome

I've used GWT a long time ago, but not at all in this way so not sure there. Could you use a Map instead?

frozen portal

not sure

sudden dome

also, are you importing any library for the JSONObject ?

frozen portal

but I might just scrape the runnables and just define all the different callback setters inside the Socket implementation

that way it knows what to do by default

it's not like I'm making custom callbacks depending on conditions anyways

just "when you get this data, do these things to these variables"

sudden dome

yeah, I think more or less you're dealing with serialization/deserialization there, where you're losing type information as it's deserialized, so everything is a bunch of Objects

frozen portal

perhaps (big words 😵)

sudden dome

serialization = converting objects/data to bytes, and deserialization converts bytes back to objects

frozen portal

Well then I don't think that's true, since the novelty of Socket.IO is that instead of having to serialize everything some basic data types like String and JSONObject as directly sent and recieved

It's just that if I want to make a general "on" method work I need to allow for any type of data since the parameters to respond to certain callbacks may be different

sudden dome

more or less, that's what happens, though -- all the data that's deserialized is some type of Object, but you don't know what without looking at some other information

so you can write a generic event handler which takes the varargs Objects, but you won't know what those represent for sure

so then you'll need to look at some data to determine what type the Object(s) really are, and cast them

frozen portal

right, but I'm only handling a handful of events that I know 100% info about like what's sent and what happens when recieved

pearl ore

It might be worth your while to try to see if you can get a JSON library working with GWT, IMO. Then you can just pass in a JSON to Java directly and work from there.

frozen portal

but I see what you mean

I haven't had too much luck getting libraries to work in GWT 😦

sudden dome

ahh well, maybe not -- in their sample it says they use Vert.x for the server implementation of web sockets

frozen portal

I dont want to have to redo my server side code :/

sudden dome

well for the client side it might be okay then

pearl ore

If your server is socket.io then your client needs to be socket.io. It uses web sockets but there's a lot in the middle that they add to make it cleaner to use.

sudden dome

Hmmm could be. I thought they just added some fallbacks like long-polling and other methods

frozen portal

i came up with I think the dumbest possible solution but itll work

without getting a JSON gwt to work, my only other option was to like, create a switch statement for the on method and do different code depending on the event id, and ALSO would require certain variable references to work

so fuck it, ill just let that class do all the work

now if I did get a JSON GWT lib to work I wouldnt have to do that but

hmm

pearl ore

Suggestion, get a proof of concept with your current method to make sure it will work (with GTW, Java, socket.io, etc., just at a basic level to make sure it doesn't not work), then you can put in the work to get a JSON library working to make your life easier.

frozen portal

I HAVE JUST DISCOVERED IM A FUCKING DUMBASS

WOW

pearl ore

Except you can only use that in your html module, your core module doesn't reference GWT. Unless you add it.

frozen portal

Oh

shoot I was already undoing code

How do I add it @pearl ore ?

just normal build.gradle stuff?

pearl ore

I think

frozen portal

oh thank god

i got scared

time to redo my undoing

trying to figure out how to write this stuff again...

nvm i dumb

I lost some cool information I was having before

now it's "get" and I have to cast to string :/

frozen portal

my eyes...

just finished the transition... i guess I can try actually running this now (on desktop) 😮

pearl ore

🤞

frozen portal

I got an answer from the server!... but it's still sending the data in the wrong form
Exception in thread "EventThread" java.lang.ClassCastException: 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 hope making the server send GWT Json objects rather than regular Json objects isn't going to be horribly difficult

@pearl ore

pearl ore

What's your code on the client side from socket.io to Java?

Like your native function I guess

frozen portal

oh my god you're right

i am very tired, sorry

Oh god now I understand

what I will have to do to make this cross-compatible

between desktop and HTML

oh my god no

well its fine the desktop build is only for myself to test with anyways...

maybe if the game gets popular I'll release a desktop version and THEN the trouble will begin

for now I can keep being dumb about it right @pearl ore

pearl ore

Apparently not too bad, looks like there's a few Socket.io libraries in C++ and Java. 1.x, but still. You just have to downgrade socket.io on your server if you're using >2 and then get a different JSON library instead of using GWT

frozen portal

Wait what?

I dont understand what you mean

You mean, what I would have to do if I wanted to be cross-compatible?

pearl ore

Yea

frozen portal

oh okay

yeah better not even think about it for now

Uh oh... I have bad news

``` still happens after I made sure that my GWT socket implementation used GWT Json

this is the method:

    public void emit(String event, Object... args) {
        try {
            JSONObject data = new JSONObject();
            for(int i = 0; i < args.length-1; i+=2){
                data.put((String)args[i], (JSONValue)args[i+1]);
            } socket.emit(event, data);
        } catch (JSONException e) {
            System.out.println("SOCKET.IO: Error sending data to server in \"" + event + "\" event.");
        }
    }```

the import is correct

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;```

maybe I should reload my project and it just didnt update

let see

pearl ore

This is from Java to JavaScript right?

You can't cast an Object to a JSONValue like that

frozen portal

I suppose, if you mean JS as in my server

pearl ore

You need to instantiate it

(JSONValue)args[i+1]

frozen portal

wait, what do I instantiate, the value?

foo = args[i+1];```???
pearl ore

Well, okay. That's actually not what's causing the exception.

I take it back lol, a bit tired

It might be an issue but better to tackle one thing at a time

frozen portal

(reloaded and it still happens)

Oh wait a dang minute

pearl ore

For some reason it's using org.json.JSONObject instead of com.google.gwt.json.client.JSONObject

As far as I can tell

frozen portal

I think I know what happened!

So the first time I got the error, it's because I had sent the non-GWT friendly JSON data and expected to get GWT-friendly JSON data

I think that as a result of that, the connection with the server broke, the server didn't finish initializing me as a player, and thus the information that I disconnected wasn't sent after I left

Meaning that the server is still holding old data that is non-GWT friendly

so lets try restarting the server and see if that fixes it

does that sound possible @pearl ore ?

ok nevermind, i was wrong

pearl ore

non-GWT friendly? JSON is JSON

The only thing that matters is that it's going from JS --> Java and Java --> JS correctly

frozen portal

ah yeah makes sense, when it goes to the server it doesnt matter whether is gwt json or not

the server sees it all the same

so what could the problem be?

I don't think i'm sending normal json anywhere

pearl ore

I mean the exception is hinting at it

For some reason it's using org.json.JSONObject instead of com.google.gwt.json.client.JSONObject
As far as I can tell

frozen portal

right, but why?

pearl ore

Why indeed 😛

Probably an import somewhere, dunno

frozen portal

could it be because my gwt socket io interface uses these?

import io.socket.client.Socket;```
pearl ore

AFAIK imports are transitive, see if there are imports in those classes that are messing with anything

frozen portal

I think the names I'm using might be confusing me
I'm calling the browser/other modules one "GWT socket interface" because socket.io doesn't work with GWT
and the HTML one "JSNI socket interface" because I'm using jsni (am I? i dont even know yet lol)

but that's dumb

ill just call them "Web" and "NonWeb"

I'm sorry, I checked all imports but I see no mention of org.json JSON objects 😐

@pearl ore 😰

i'm not using it, but......

pearl ore

Hmm

frozen portal

should I just grab the java library, replace all usages of JSON to gwt json ones, compile it back to a jar [THING I DONT KNOW HOW TO DO YET] and import that as a library?

pearl ore

Are you able to get rid of your try-catch statement and just let the exception happen? It'll help pinpoint exactly where it's happening

Or debug and step over and try to find it

frozen portal

It's not getting caught

ill debug

should I do what I said above @pearl ore ?

pearl ore

What Java library?

frozen portal

yeah should I just make my own custom copy of it

I don't know how to turn it into a jar so I can import the library yet

pearl ore

?

This doesn't sound kosher lol

frozen portal

What part of it sounds bad

pearl ore

should I just grab the java library, replace all usages of JSON to gwt json ones, compile it back to a jar

frozen portal

where's the issue?

im guessing that might not be okay but I dont get why

pearl ore

There's almost never a need to do that. The only time I've ever seen it done was to swap out XNA for MonoGame in Terraria.

What library are you referring to?

frozen portal

I'm guessing since they never intended for any of it to be GWT-compatible they didn't think to use GWT-compatible classes

So when my app recieves JSON data it will automatically assign it to a org.json JSON object

and after that from what I understand it's impossible to convert one into the other

pearl ore

Hang on, let's take a step back. So you have LibGDX with a desktop and HTML targets. Then you are referencing the Java Socket.IO library. Which doesn't work in GWT, of course (if I found the same one you did). But then you are using the JavaScript version of socket.io so that it can be used in GWT?

Or am I missing something

frozen portal

currently I still haven't done the HTML implementation of my Socket interface, I'm still on the non-web one

which simply calls methods to the Java Socket.IO library that I already have

what I was proposing was to modify that library so that it transfers gwt JSON objects and not org.json ones

if you have a better solution of course i am all ears, im just making uneducated guesses

pearl ore

Ah, okay. So personally, I'd stick with org.json when you're using core. That way core doesn't need to reference GWT. You can convert from GWT's JSONObject to org.json's JSONObject in your implementation when going from JS --> Java and Java --> JS. Simplest way is to stringify the JSON and then have the other type decode it back.

Or you can do it from JavaScript. Instead of the native function returning JSONObject, return string and just do return object.stringify();. Then you can decode it into an org.json.JSONObject.

frozen portal

You mean, decode it into a gwt JSONObject? that sounds good

if thats what you mean

@pearl ore Is that what you mean or did you really mean decode it into a org.json JSONObject

pearl ore

So from Java --> JS, Java uses org.json.JSONObject. Inside your implementation in your html project, you can convert from org.json.JSONObject to a string (stringify the JSON object). When you call the JS native function pass a string instead of a JSON object (static native void js_Function(String jsonStr), for example). Then your JS function can parse it into a JSON object (let jsonObj = JSON.parse(jsonStr);) and send it off to socket.io.
From JS --> Java, have the function return a string (static native String js_Function(), for example) and your JS can stringify the JSON object before returning it (return JSON.stringify(jsonObj);). Then you can turn that string into an org.json.JSONObject and pass it back.

That way your core only uses org.json.JSONObject, which is what the Socket.IO library uses anyway.

frozen portal

Just to be 100% clear, when you say "Java --> JS" or back, you do not mean "Client --> Server" (server being in JS), right?

pearl ore

Nope

On your client, you have to call JavaScript at some point in order to use the JavaScript version of socket.io. That's what I'm referring to.

frozen portal

Alright

Currently reverting to using JSONObject so I can test for Desktop and be 100% that this can work, then we'll worry about JS

should be good soon

Great, the game totally works! 😄

for desktop

The interface only uses 3 methods

@pearl ore

I KNOW this is a dumb thing to ask

and you're probably facepalming

but uh how do I make it understand this is JS

(At least when I'm through with figuring this out I'll be able to release the basic LibGDX app working under this source.io framework for cross-compatibility so people won't have to go through the same struggle 😄 )

@pearl ore sorry for pinging (its getting very late)

pearl ore

Semicolon

After the comment

frozen portal

ohhh

i was looking at how the library I linked yesterday was doing it and I didnt notice that

thanks

now I gotta figure out how to do the thing you said and I'm almost out of libgdx hell

while im figuring it out here's the start of the class and I'm certain I didn't do it right

as in there is nothing I've written that would point towards the JS library

and also I'm using the incompatible JSON objects but I know I have to change that

@pearl ore

are you here?

frozen portal

man we're getting close to getting this working, im happy

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