❔ everything returns errors
I want to fetch the screen width, divide by 1920, fetch the screen height, divide by 1080, choose the lowest number, and scale all hud elements based on the number chosen, but nothing seems to work.
36 Replies
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
The important part here is including what framework it is.
and/or if it's a game engine / game framework
Okay I'm using .net 4.8 visual studio
Right, "nothing seems to work" is too vague for us to help.
What did you try to do exactly? ($code)
What result did you expect?
What went wrong (exception message or the result didn't match expectation)
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/WinForms, WPF, Console .. What?
I don't know how to check, I'll google it and get back to you
Usually, you choose one of those at the beginning when you set up your project
You can just show solution files and I should be able to tell
I mean I could recreate the 10-15 failures if you want, but it's a vague question because it's a broad problem 🤷♀️ I don't understand the fundamentals, and I've detailed the effect I want to achieve. Any step in the right direction is my goal for today, but I hit a wall
Oh that makes it easy, lemme check
this here is my solution
Ah, SDL2?
yes
SDL2/SDL_GetWindowSize
The Simple Directmedia Layer Wiki
woah theres a wiki?
thanks man :)
That's for C++, but I'm guessing the C# lib is just a wrapper (binding)
So it should theoretically be the same, except with few tweaks, such as with C# you usually don't have to use pointers.
alright I managed to get the errors from 8 down to 3
Do not copy paste what it says
That is only the declaration of the method.
C# is different from C++, because you don't use pointers and references in the same way.
Are you using this library? https://github.com/flibitijibibo/SDL2-CS
GitHub
GitHub - flibitijibibo/SDL2-CS: SDL2# - C# Wrapper for SDL2
SDL2# - C# Wrapper for SDL2. Contribute to flibitijibibo/SDL2-CS development by creating an account on GitHub.
I am pretty sure, yes. I'm not entirely sure that that's the exact release, but the code I am building off of was given to me specifically by ethan lee/flibitjibibo
Use the function already defined in SDL2.cs
SDL_GetWindowSize
https://github.com/flibitijibibo/SDL2-CS/blob/master/src/SDL2.cs#L1910you legend
I mean call it
SDL.SDL_GetWindowSize(..)
I believe it is, unless I've misread it.
That file is huge.
This will do nothing.
You should not re-define it as it exists in the SDL class already.
so it should look something like this
MyWindowHandle
being the handle of your windowI think I understand, thanks! Sorry I'm a slow learner haha, the only productive way of learning i've had is pattern recognition. Anyway, I don't understand "MyWindowHandle" but I think I understand width and height
So that defines width and height as a variable, so that when I want to divide height by 1080, it understands what 'height' is
My question is doesn't this require a trigger? Does it just always know what width and height is even when the window changes, or do I need to give it instructions on when to print height?
I assume you lack the basics, because whatever you're saying makes little sense
$helloworld
Written interactive course https://learn.microsoft.com/en-us/users/dotnet/collections/yz26f8y64n7k07
Videos https://dotnet.microsoft.com/learn/videos
$projects
Collections of application ideas that anyone can solve in any programming language to improve coding skills:
https://github.com/ZacharyPatten/dotnet-console-games
https://github.com/karan/Projects
https://github.com/florinpop17/app-ideas
learn the fundamentals, like functions, variables and memory
I do :( all the guides I found are either paid (I have no money) or just not helpful. I'll check out the things you sent and give it a look, i've got exactly 6 months to finish my project
just download any programming book and go through the first few chapters
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.from what i can tell, the ui for the game they are trying to scale the ui for is made for 1920x1080, so they want to divide the current resolution by the default resolution so instead of looking pretty bad in any resolution other than 1080p it looks good enough
for me programming books never worked (but thats just me)
i learned c# mostly by starting with porting mods for tmodloader (a terraria modloader) from 1.3 to 1.4 (biggest update, but relatively simple stuff, mostly regex and asking for help in the server, this was before the automated tModPorter tool released)
then i wanted to code something myself, and learn web requests, so i made a tool to easily download different versions of applications from the PaperMC api using WinForms and System.Text.Json
i also helped someone make a simple text-based game in c#
i added:
saving
leveling
abstract enemy and item classes
and more
without the c# discord server, i probably wouldnt be coding in c# today
heck, i would probably still be coding in batch and powershell
my tips are: be patient, and learn the way it works for you
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.