Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 08:44

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Help 2d game classes

Discussion on Help 2d game classes within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
Help 2d game classes

i want to develop a simple game, just for fun and practice coding, i hardcode so bad that i give up doing that way and want to implement the correct one

I made a class diagram in rational so anyone can understand what i want, and what is wrong.



Want to know:
1- Is anything bad implemented?
2- Should i change setState to be a static method?
3- Is ok that gameCamera is static?
4- Things to improve

Thx for your time
elmarcia is offline  
Old 05/18/2016, 21:29   #2
 
elite*gold: 0
Join Date: Jul 2009
Posts: 211
Received Thanks: 137
I might have a few things.

Designing games is a well studied topic. There are a lot of design-patterns like an event-queue or the update-loop if you are interested a few more.


1. This might be just a name thing but why does your GameState need to be renderable? You might want to look into the MVC-Pattern to seperate logic, data-model and view. For someone who is new to programming this pattern is awful but it makes it easier to switch the view if you want to change it later.

2. & 3. Static mutable states are problematic especially if you change the states from different threads.
  1. Do you need to access it from everywhere (and always the same instance) and it is not a constant? --> Make it a Singleton with thread-safe methods
  2. Is it a constant? Make it static-final
Other OO-Languages don't use the static concept because static members kinda destroy the whole OOP paradigm. So only use static members if you really need to. Scala for example doesn't have static members if you want a static method or constan you always put it into a singleton-object.
Mysthik is offline  
Thanks
1 User
Old 05/19/2016, 00:44   #3
 
Achat's Avatar
 
elite*gold: 528
Join Date: Jan 2012
Posts: 2,127
Received Thanks: 2,403
Wow, with what did you create that diagram? Could really need something like that.

It's difficult to tell you something only based on the diagram, but my improvements for you:
  • never use public attributes
  • don't use static except when really necessary
How is player supposed to jump if the method is private?

Other questions that came to my mind:
  • How is data workflow?
  • thread-safe? threads?
  • separation of data, gui, network etc?
  • Did you actually code something yet? Or did you just "design" classes?
Achat is offline  
Thanks
1 User
Old 05/20/2016, 20:14   #4
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
I did some code, and jump is bad implemented because when player call update will register input and if is needed key will jump. So the diagram too

Those diagrams are made in rational from ibm
I have full version from my university =)

Quote:
Originally Posted by Mysthik View Post
I might have a few things.

Designing games is a well studied topic. There are a lot of design-patterns like an event-queue or the update-loop if you are interested a few more.


1. This might be just a name thing but why does your GameState need to be renderable? You might want to look into the MVC-Pattern to seperate logic, data-model and view. For someone who is new to programming this pattern is awful but it makes it easier to switch the view if you want to change it later.

2. & 3. Static mutable states are problematic especially if you change the states from different threads.
  1. Do you need to access it from everywhere (and always the same instance) and it is not a constant? --> Make it a Singleton with thread-safe methods
  2. Is it a constant? Make it static-final
Other OO-Languages don't use the static concept because static members kinda destroy the whole OOP paradigm. So only use static members if you really need to. Scala for example doesn't have static members if you want a static method or constan you always put it into a singleton-object.
I will use mvc pattern to split logic and views, but by now i prefer learning with something that i can iterate over and over again and see how is its behaviour and when i'm happy with my logic making independant from view is easy
elmarcia is offline  
Reply


Similar Threads Similar Threads
[Buying] Game (PvZ garden warfare 2) typeinfo classes help
02/26/2016 - Coders Trading - 0 Replies
Hello, I am looking for a coder who can help me with PvZ garden warfare 2 rank xp and coins modifying. I know and I am able to do it through memory editing via CE, but I want to know how to do it via typeinfo classes. If you think you can help me, please PM or reply. lokki123
[Int] Bot for all Classes
04/06/2012 - Kal Hacks, Bots, Cheats & Exploits - 1019 Replies
This bot should work for every class. Its the Bot from katze123, cracked ofc. How to use: Copy dlls to client folder and check .ini files Commands: commands test test2 test3
new classes, need help.
11/21/2011 - Dekaron Private Server - 8 Replies
I have some problems with concerra and seguriper. This is what I need help with: 1. Concerra weapond is just 1 blad, it should be dual on grafic. 2. Texture for seguriper, have concerra texture working already. 3. Party bug for seguriper. (concerra fixed) 4. Mainbar image for aloken, concerra, seguriper. (class image) 5. Need to know what DEKARON ** 000001 I should use. I hope anyone can help me with this.
All classes +7/+8 / 1 bil SIZ
06/29/2011 - Dekaron Trading - 3 Replies
Incar Magician -Izar helmet +7 full sloted -Canopy boots +7 magic 2 x option -Canopy boots +7 magic 2 x option -Perkad full sloted +7 Segnale -Jubanx helmet +7 full sloted -Jubanx armor +7 full sloted 2 x magic options -Jubanx pants +7 plain
c9 classes
02/12/2010 - C9 - Continent of the Ninth - 0 Replies
Fighter http://images.hangame.co.kr/hangame/c9/obt/sub/im g_job_fighter.gif Hunter http://images.hangame.co.kr/hangame/c9/obt/sub/im g_job_hunter.gif Shaman http://images.hangame.co.kr/hangame/c9/obt/sub/im g_job_shaman.gif



All times are GMT +1. The time now is 08:44.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.