Design Questions on 3rd Edition Code

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Design Questions on 3rd Edition Code

      Hi. I'm hoping this is the place to ask some questions about the 3rd edition code -- and that they are still being answered.

      I found the 3rd edition book a few months back. It was just what I was looking for. I have downloaded the code, and after some fun got it running. (I only have VS2005, so I can't move up to the 4th edition.)

      There are a couple of design/structure issues I've come across that I'd like to discuss. Before I go into detail on them, I wanted to make sure that this was the right place and still a valid subject. Thanks.
    • There is a book forum for Version 3 , most of the topics in version 3 carry over to 4, ask away and we'll try to help.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Edition 3 was a pretty long time ago - but sure ask away and I'll see what I remember! There were big changes made in the 4th edition, especially in graphics, editor design, and in the Lua scripting system to name only three.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Hey guys. Thanks for the replies.

      Here's a problem I found (and fixed) that is somewhat related to what I want to ask about --
      When I got the game running I found I was getting "No Such Actor" asserts, when I shot at and hit the opposing teapot. They came from the VRemoveActor call that followed the VRegisterHit call (in TeapotWarsGame.cpp). The problem was that VRegisterHit internally called VRemoveActor just before it returned. I commented out the VRemoveActor call generating the asserts. (I didn't see this issue in the forums. Did I miss it?)

      I also found that there was code (in HandleEvent of TeapotWarsView.cpp) to play a sound when there was a collision between a sphere and a teapot -- but the sound never played. That was because the sphere actor had already been removed by the VRemoveActor call in TeapotWarsGame.cpp. So the routine never saw that one of the actors in the collision was a sphere (because it was no longer defined).

      I wanted to "fix" this but didn't think there was a way to ensure which subscriber to an event gets notified before another. After a bit of thought, I decided the best way was to add a new event (just to play the "hit" sound) and have TeapotWarsViewListener subscribe to it (in place of the Collision Event processing). The event would be generated (indirectly by the Collision Event) in VRegisterHit (just before the VRemoveActor call), and would be a Trigger type event (so the sound would by timely with the hit). There wouldn't be any need to check actors, since the routine generating the event did this (and it was within the game logic part. I thought it important to keep any game logic out of TeapotWarsView to keep the structure clean/correct.). It worked nicely.

      My question is, how should this really have been done? The method I used (the trigger event) works, but I'm concerned that it may not for the network case.
    • I'm trying to remember the 3rd edition code base.....

      Your fix sounds reasonable to me based on what you said. Separating it into two events sounds like the correct thing to do.

      Of course, in the real world, I would solve that problem in exactly the same way I did for the 4th edition: by ripping out that entire actor system and replacing it with the actor/component system. ;)

      -Rez
    • I think a special event sent by the sphere actor upon collision would have been the right way to do it...and then the actor itself should hang out in limbo for at least one frame before being deleted permanently.

      It's last part that I don't think existed in the 3rd edition code base, and one of the many reasons Rez wisely wanted to remodel it completely.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Mr. Mike, Rez,

      I really appreciate both of you taking the time to venture back into your "mental archives" and give me a reply.

      I'm still wondering if my approach would be valid for the remote case. I'll have to take some time to think that one through.

      Based on what you've said, I think I will have take a good look at the 4th edition code. Do you know if it would build with the Express edition of VS 2010? It would be really interesting to see and study how the 4th edition game runs.

      Just one more question. I was thinking that the sphere shouldn't just be able to score a hit after rolling endlessly. But instead it should self-destruct after a certain amount of time or distance. Any thoughts on how best to approach/implement that?

      Again, thanks for you time and expertise.
    • Just one more question. I was thinking that the sphere shouldn't just be able to score a hit after rolling endlessly. But instead it should self-destruct after a certain amount of time or distance. Any thoughts on how best to approach/implement that?


      Processes seem like a good candidate for this one, I'm unsure if that is in the 3rd edition, but essentially it is a cooperative multi-tasking system which is given a slice of time each frame, you can make a process that could

      1. Tick a timer, and check for completion
      2. Update a text item to show the timer whenever it rolls around a 1 second mark
      3. On completion of the timer, create some cool effects/sfx and do some area damage
        [/list=a]
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz