Re: About C#. Keys

Hi there,
wow, such a discussion, but we are joining together slowly I  guess.
@Ethin: when two share the same opinion, how can they argue about it? smile
You wrote, that I want to use gui loop for a videogame. can you quote that? because I have never wrote this.
I have wrote, that you can use gui system for audiogames. And that is a difference. You can actually make even some simple fps without noticing any bugs. In audiogame there is no stucking drawing, so only way you can find that something is going wrong is when reaction to key press comes later than it should (of course meaned during actual gameplay).
When you are planning to make an audiofps with thousands of enemies and tons of objects in 3D map, you can use game loops to save cpu. But you still have a chance to do it.

If you are planning to make actually a videogame, well, that's completely different situation. It isn't a framework loop what actually stops you, but simply unability of gui systems to draw content in 60 fps. if you want to do such a operation, you need firstly to know the surface, then calculate view angle, what is visible, what is not, how to view it and just after that comes actually the drawing, also with some technologies to speed it up. That is something gui systems weren't developed to manage.
There is OpenGL as you say for this purpose and only a fool would use Windows forms or WPF instead.

About dividing game into window classes, I meaned to separate logics of game phases to multiple classes, instead of mixing everything in one, that would be a bad idea. But you already get it I guess, may be it was just a misinterpretation.

So you see, our opinions aren't different this time and I think situation was the same in many others of our conversations.

I know that you are good at programming, otherwise I wouldn't give you neither a second of my time and attention.
I have been coding synce my 11, that's about 6 years. So I have some experiences too, don't worry about it. smile

@Sanslash: BgtKit isn't published yet. It has two reasons. First that I was coding it during development of my games, and because of that just functions I actually needed are implemented. Second is, that it is some time synce I worked on some game, i am focusing more on expanding my knowledge to web technologies and mathematics, including machine learning, deep learning and artificial intelligence.
So I am not currently interested in BgtKit much.

And now, to all of you, who want to begin with programming audiogames. There were tons of examples from people like Mason, Gorthalon, etc. how to do an audiogame in bgt. But many of them shared the same mistake - spaghetti code.
In programming, a spaghetti code is a code, which uses just few or no classes and relies on functions, which aren't in any class. Something like that is very chaotic and hard to extend.
Another common mistake was using global variables, in bgt frequently for nearly everything. To make it clear, there shouldn't be any global variables or functions in your projects, everything should be at least at class level.
If you need to make it available from every class, use a static class for this purpose, which represents what category that variable belongs to.
For example, Math functions in C# aren't declared like globals, even if that were possible, but are grouped in a static class Math, what is pretty clear explanation of their category.

To react on these problems, I have developed a system of developing a game, which separates its phases to classes called Windows, or VirtualWindows better said. They are there to manage keyboard presses, mouse motions, joystick actions and other input from user, while a timer method cares about moving enemies, weather, time, healing you etc.
of course those things should be actually made in other classes, for example you should to have a class Player, which stores player's health and Window method just updates it when necessary. Physics should for example have its own class, mapsystem too, as Sanslash already pointed out.
VirtualWindow is somewhere in the midle making the colossus of classes work.
This is independent on language, you should use object oriented programming in C#, Python, Java, _javascript_, Kotlin and whatever you are able to think out, of course if it supports it. smile

As I promised, I have coded a small example of what I mean. I have found out, that I don't have necessary sound effects to do sidescroller or fps. I would be forced to steal sounds from other project and that is something I don't want to do. No publicly. big_smile
So I have coded a small Slide like game. You may know it, there is a grid of squares with numbers, just one square is empty and you must to sort them by moving to that empty square.
There is a menu, where you can choose if you want to play with 3 x 3 or 4 x 4 grid. Although I made the algorithm universal, so it can be used for every size starting from 2.
Actual gameplay is straight-forward, arrow keys allow you to navigate around the grid, if you hold shift and press an arrow, currently targeted square will move in that direction- if it is empty.

From code perspective, I recommend you to pay special attention in KeyboardShortcut class and its functionality, also check a hierarchy of VirtualWindow, how are virtual methods implemented defaultly, when is needed to override them and when not.
If you don't understand anything, feel free to ask.

For more experienced programmers, I would like to hear also yours opinion. Is there something to improve on this system in your opinion?
For example, I am thinking, if it is right to use Speak method inside of Window class. Or playing sounds. Of course actual logic is in classes, but its use must be related to its source somehow. So the question is, where exactly.
I have tried various approaches, but thisone seems the most practical and readable for me.
Also when assigning keyboard shortcuts, there should be a constructor of Keyboardshortcut class, which takes shortcut as a string and parses it inside of the class imo. It would a. clear the syntax from keyboardShortcuts[new KeyboardShortcut(true, false, false, Key.A)]=method; to keyboardShortcuts[new KeyboardShortcut("control+a")]=method; b. it would free programmer from including System.Windows.input to get Key enum.
Also when that is done, declaring keyboardShortcuts as a property with slight edit of its setter would clear previous syntax into this:
SetKeyboardShortcuts({
"control+a" = SelectAll,
"control+home" = GoToTop,
"control+end" = GoToBottom,
...
});

That seems much better like tons of if statements we used previously in bgt for me. Of course this input would parse internally to Dictionary with keyboardShortcut class, so actual look up would be as fast as possible.

I think that is all I wanted to say. If you want to check it out, you can download from:
http://leteckaposta.co/file/564857137.1 … 0a2cc5c/cs

Happy coding

Best regards

Rastislav

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : sanslash332 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : alisson via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : sanslash332 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : sanslash332 via Audiogames-reflector

Reply via email to