Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

170 Neutral

About subflood

  • Rank
  1. So, by definition, the controller is not working great, since it's not doing the job it's supposed to - it can't control. Lets take my pong example again. Obviously the AI controller will need to know the paddle's and ball's location in order for it to make a decision where to move.[/quote]Under canonical MVC, you would encode this into model and view and controller would remain dumb. The feedback from possible invalid moves would then be modeled as event from model that controller and view would subscribe to. Since this loses the coupling, one would need to tack on a full request/response pair handling mechanism, since each request would need a confirmation. This introduces the need for transactions. Transactions can result in deadlocks, which means a transaction broker must be added along with a priority handling system. And since behavior in model would need to change, it would be defined using policies, strategies, rule engines and external scripted logic. And at this point - you have reinvented the full-blown enterprise-grade application stack. Everything is correctly decoupled, everything is nice and modular, but suddenly 99% of infrastructure is just plumbing - instead of having direct access to state and saying "if (!moveValid()) return;". This is precisely why enterprise frameworks (.Net, JEE) become such beasts. They model everything and each requirement complicates by covering fully orthogonal functionality, resulting in dimensional explosion. But they cover everything. Omitting any of the above exposes a potential authority or logical problem where some behavior may "fall through the cracks" and ends up being difficult to fix or looks like a hack, making it difficult to extend and maintain. One problem with MVC is that it's encapsulation is inherently orthogonal with how the simulation works. MVC tacks everything into objects, treating them as independent entities. But in reality, the simulation updates entire state at once, over and over. It never updates objects independently, even if MVC tries to present it as such. So the proper organization, rather than focusing on individual entities is to turn things around - design everything around state. State is the board:List<Entity> entities; List<Mob> mobs; List<...> ...;Next, the controllers get access to the state - not individual entity. Same for view - it's not a completely separate entity, it works in tandem with model and controller. Then on each step:update_controllers(state); update_view(state, controller_results); update_simulation(state, view_results); render(); The "xxx_results" is a list or some other storage which collects the updates to transfer between systems. Controllers might report collisions or UI feedback (screen flash). View will then show up buff icons, change full screen alpha to red and similar. How exactly this ends up being structured is not all that relevant, the key is to treat state (aka model) as a whole to which each other system has access as a whole. There simply isn't any benefit in trying to pretend that A is forbidden from knowing about B. Low coupling is achieved differently, mostly by not going crazy in inheritance and abstractions. [/quote] If the controllers know about the entire state how do they know which objects to communicate with? Is it just: for(Gun : state.gunList) do this
  2. I have the controller taking in input from a device, which works great. The problem comes in when I try to implement an AI. Lets take my pong example again. Obviously the AI controller will need to know the paddle's and ball's location in order for it to make a decision where to move. My question is where does the controller get this information from? Is it the entity that passes along this information or the entity manager or something else? thanks for the feedback.
  3. I was reading about an MVC architecture from this article: http://www.gamasutra...code.php?page=2 There are a few things I'm unclear about. Lets use a simple pong game as an example. We have two entities (models) paddle and ball. A paddle has a controller which can get input from a keyboard, mouse, or whatever else. Based on the input the controller decides what the paddle should do. So for example, if I press the up arrow on my keyboard the controller will receive that and will set a direction variable to up. The model will then poll its controller for the direction and move accordingly. My question is how exactly is the paddle's controller supposed to handle collision with the ball or the other way around. How are the models or controllers supposed to interact with other models. Is the controller even supposed to know about its specific model? It doesn't seem like this is the case according from this diagram (from the article): [media]http://www.gamasutra.com/features/20050414/rouwe_00_clip_image002.jpg[/media]
  4. subflood

    Joy to the world!

    Wow, like minded people what a change. Let me tell you how ridiculous the christmas event can be. My mom sent me to the store today to buy christmas cards for the entire family because she didn't have the time to buy any gifts. So I went to the store and I bought three cards for her and three cards for me. My mom and I then decided that we were going to put an equal amount of money inside each of the cards, one card for everyone in the family. Later in the evening, we exchanged these gifts, which basically boiled down to me taking money out of my checking out and my mom taking out an equal amount of money out of her checking account and then exchanging it with me. The food was great though.
  5. subflood

    Ray Tracer: Generating Rays

    Ok, I changed the field of view to a much smaller value and now the image looks a lot less distorted. Here is a screenshot of my ray traced image, still in the early stages: Thanks you all for helping.
  6. subflood

    Ray Tracer: Generating Rays

    Vilem Otte and stonemetal, what you describe is what I'm doing. However, when I render the image the spheres are somewhat distorted. In the image below the bottom right sphere seems distorted, just like in my ray tracer: I figured that maybe this is normal but other images such as the one below don't seem to suffer from this problem:
  7. subflood

    Ray Tracer: Generating Rays

    I'm simply asking how to do perspective projection. I have a camera that generates rays but I don't know how to properly calculate the ray's direction.
  8. Hello, I have learned that given a point x,y,z in 3D I can find its corresponding 2D point by this math: x' = (d*x)/z y' = (d*y)/z z' = 0 this makes sense. However, I'm not sure how I can implement this in my ray tracer. Currently I have a camera positioned at (0,0,0) and an image plane with size 800x800. At each iteration a ray is assigned origin (400,400,0), which is the middle of the screen, and the direction is the difference between the current image plane's pixel location and the origin. Here is an image that describes my technique: http://www.devmaster.net/articles/raytracing_series/part1.2.jpg However, I think there is a better way I can determine the ray's direction by using the theory I stated earlier in the post. Is there? Thank You.
  9. Thanks for your help. Unfortunately, I won't have time to try this out until next week. I'll post my results then.
  10. Quote: Create the cumulative distribution function, I searched the internet for one but I can't find it. Quote: map a set of linear random numbers [0,1) to velocities by using that. Can you elaborate a bit more on this because I'm not sure what you mean.
  11. Hello, I want to write a simulation of the ideal gas law but I'm having some trouble with the math. I have a few particles/molecules and I want to assign to each of them velocities using the maxwell distribution (the equation is given in the "Distribution of Speeds" section of the article). However, since this is just a probability function I'm not sure how I can create a function that will fit the velocities according to the distribution. Of course a program like this has been done before but I'm just doing this for fun and learning purposes. Here is a link to what I want to achieve: link. Any help is greatly appreciated.
  12. subflood

    Simple C++ question

    Quote: I have no idea what it means, I tried adding this "#include "stdafx.h" and "stdafx.h", but nothing works, I am sure by reading this (Only thing it is telling me) you will know my situation, oh and I do use the Visual C++ 2008 express edition. When you make a new project in Visual Studio make sure you make an EMPTY win32 console application and uncheck the "precompiled header" check box. File->New Project Choose win32 console application Hit Ok Hit Next Application Type: Choose "Console Application" Additional Options: Choose "Empty Project" UnCheck "Precompiled Header"
  13. subflood

    void pointers

    Hello, I'm coming from a java background trying to learn c++ from an online book "Thinking in C++." I have come to an interesting exercise in the book and was wondering why it works. Here is the code: #include <iostream> using std::cout; using std::endl; class Bird { public: void fly(); }; void Bird::fly() { cout<<"Flying"<<endl; } class Rock { }; //Flying Rocks int main(void) { Rock r; Bird b; void *p; p = &r; b = (*(Bird*)p); b.fly(); return 0; } Shouldn't you get some kind of runtime error when running this? Just curious how this works internally.
  14. subflood

    space transformations

    This is from an example and it uses D3DFVF_XYZ. The only transformation the code performs is a projection using D3DXMatrixPerspectiveFovLH. Now since no view transformation was performed, where is "the camera" located, how does direct3d determine this?
  15. subflood

    space transformations

    Yes I'm talking about a simple 2D triangle. I'm just confused on what happens when you give the coordinates for a triangle to Direct3D. How does Direct3D decide what part of the screen in visible?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!