C
C#2y ago
Lemur2591

❔ 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
Buddy
Buddy2y ago
$details
MODiX
MODiX2y ago
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)
Buddy
Buddy2y ago
The important part here is including what framework it is. and/or if it's a game engine / game framework
Lemur2591
Lemur25912y ago
Okay I'm using .net 4.8 visual studio
HimmDawg
HimmDawg2y ago
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)
MODiX
MODiX2y ago
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/
Buddy
Buddy2y ago
WinForms, WPF, Console .. What?
Lemur2591
Lemur25912y ago
I don't know how to check, I'll google it and get back to you
HimmDawg
HimmDawg2y ago
Usually, you choose one of those at the beginning when you set up your project fluffyFoxLurk
Buddy
Buddy2y ago
You can just show solution files and I should be able to tell
Lemur2591
Lemur25912y ago
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
Lemur2591
Lemur25912y ago
Lemur2591
Lemur25912y ago
this here is my solution
Buddy
Buddy2y ago
Ah, SDL2?
Lemur2591
Lemur25912y ago
yes
Lemur2591
Lemur25912y ago
woah theres a wiki? thanks man :)
Buddy
Buddy2y ago
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.
Lemur2591
Lemur25912y ago
alright I managed to get the errors from 8 down to 3
Buddy
Buddy2y ago
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.
Buddy
Buddy2y ago
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.
Lemur2591
Lemur25912y ago
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
Buddy
Buddy2y ago
Use the function already defined in SDL2.cs SDL_GetWindowSize https://github.com/flibitijibibo/SDL2-CS/blob/master/src/SDL2.cs#L1910
Lemur2591
Lemur25912y ago
you legend
Buddy
Buddy2y ago
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
SDL.SDL_GetWindowSize(MyWindowHandle, out int width, out int height);
// your width of window is now held in variable 'width'
// your height of window is now held in variable 'height'
SDL.SDL_GetWindowSize(MyWindowHandle, out int width, out int height);
// your width of window is now held in variable 'width'
// your height of window is now held in variable 'height'
MyWindowHandle being the handle of your window
Lemur2591
Lemur25912y ago
I 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?
Anton
Anton2y ago
I assume you lack the basics, because whatever you're saying makes little sense $helloworld
Anton
Anton2y ago
$projects
MODiX
MODiX2y ago
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
Anton
Anton2y ago
learn the fundamentals, like functions, variables and memory
Lemur2591
Lemur25912y ago
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
Anton
Anton2y ago
just download any programming book and go through the first few chapters
Accord
Accord2y ago
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.
Trace
Trace2y ago
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
Accord
Accord17mo ago
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.