OMEGANAUT

Post screenshots, binaries and projectfiles of the projects you have made with ZGE that you want to share!

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

OMEGANAUT

Post by Ats »

Hi everyone !

I discovered ZGameEditor two days ago. I was amazed by the simplicity and efficiency of it. So after going through the "avoid walls" tutorial, I made this simple game this morning.

Now I have some questions for you... For starters, let's talk about the enemy color change. I made that using the Condition component within the Render part:

Code: Select all

<OnRender>
  <UseMaterial Material="SpriteMaterial"/>
  <Condition Expression="return CurrentModel.EnemyLife == 3;">
    <OnTrue>
      <RenderSetColor Color="0.502 0.502 0.502 1"/>
    </OnTrue>
    <OnFalse>
      <Condition Expression="return CurrentModel.EnemyLife == 2;">
        <OnTrue>
          <RenderSetColor Color="1 0.502 0 1"/>
        </OnTrue>
        <OnFalse>
          <Condition Expression="return CurrentModel.EnemyLife == 1;">
            <OnTrue>
              <RenderSetColor Color="1 0 0 1"/>
            </OnTrue>
          </Condition>
        </OnFalse>
      </Condition>
    </OnFalse>
  </Condition>
  <RenderMesh Mesh="EnemyMesh"/>
</OnRender>
It works, but is the logic OK ? I mean, I'm only doing 3 tests and it took me quite a long time to scroll in the list, add the component... What if I had a lot of tests like that ? Is there another, quicker method ?

I've got some more questions about random numbers and laser angle, but I'll ask one at a time :)

Thanks !
Now I'm going to try particles...
Attachments
TINStarfox.zip
TINStarfox 0.0.1
(38.3 KiB) Downloaded 1255 times
Last edited by Ats on Tue Jul 03, 2018 9:10 pm, edited 1 time in total.
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Ats,

Looks like you're off to a great start already. Star Fox is one of my favorite games of all time :)
Ats wrote:It works, but is the logic OK ? I mean, I'm only doing 3 tests and it took me quite a long time to scroll in the list, add the component... What if I had a lot of tests like that ? Is there another, quicker method?
It's more convenient to use a switch-case statement when you need more then one "test". Unfortunately (?) there's no component equivalent to that, so you need to use a ZExpression. Personally, i'd tackle your specific situation like this ..

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Model Name="Enemy">
  <Definitions>
    <DefineVariable Name="EnemyLife" Type="1"/>
  </Definitions>
  <OnRender>
    <RenderSetColor Name="EnemyColor" Color="0.5 0.5 0.5 1"/>
    <RenderSprite/>
  </OnRender>
  <OnSpawn>
    <ZExpression>
      <Expression>
<![CDATA[// Set enemy life-points to 3 

EnemyLife = 3;]]>
      </Expression>
    </ZExpression>
  </OnSpawn>
  <OnCollision>
    <ZExpression>
      <Expression>
<![CDATA[// Change life-points & color when it is hit

switch(--EnemyLife)
{ 
  case 1: // Changing from 2 to 1 life-points ( from orange to red ) 
    EnemyColor.Color.G = 0; 
    break; 

  case 2: // Changing from 3 to 2 life-points ( from grey to orange ) 
    EnemyColor.Color.R = 1; 
    EnemyColor.Color.B = 0; 
    break; 
}]]>
      </Expression>
    </ZExpression>
  </OnCollision>
</Model>
You can simply code-paste the entire snippet into App.Content ( for example ).

Welcome to the club!
Kjell
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

I didn't know that I could use switch case. And you also show me how to call functions. Thanks :D

So to my next question: the lasers direction !

Right now, I'm spawning them from the player ship with UseSpawnerPosition on. The laser itself have a Velocity.Z = -100 to move forward.

I tried CurrentModel.Rotation = PlayerModel.Rotation; on the OnSpawn of the laser. It works, but the laser keeps going along world Z axe, not along his proper Z axe.

How can the laser advance along the line made by his own rotation ?
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

looks great! keep working on it,. it should be cool in the end.

Kj gives good advice,. only using the condition checks when needed and leaving the values set in between is much more efficient,. I find it difficult when building stuff to stay optimized in my coding as I am often not sure what is needed before I try some options,. then I forget/neglect to go back an optimize. (at least until the frame rate starts to drop) anyway,. looks like a good game already,. more please.
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2320
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Welcome Ats!
I'm a fan of Star Fox too :)
Looking very nice! Smooth controls and clean visuals. Need some audio :)
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Ats,
Ats wrote:I tried CurrentModel.Rotation = PlayerModel.Rotation; on the OnSpawn of the laser. It works, but the laser keeps going along world Z axe, not along his proper Z axe.
Correct, velocity is in world-space ( which is actually what you want ).
Ats wrote:How can the laser advance along the line made by his own rotation ?
Yea .. i have no idea why there still isn't a build-in function to do these kind of things, as you need this for pretty much all games.

Anyway, check the attached example .. the calculation you're looking for is located in the Bullet.OnSpawn ZExpression :wink:

K
Attachments
Bullet.zgeproj
(2.27 KiB) Downloaded 1025 times
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Thanks everyone. It's not much of a game right now, I'm just learning how to use ZGameEngine with it. But I have some cool projects to make from that afterwards. I'm a fan of the first Starfox and Frontier Elite II, too ;)

Thanks Kjell, it worked like a charm !

Edit: Sound isn't working on Ubuntu+Wine. I'll have to switch to my other computer at some point...
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

So this is the new version :

- Added a first person cockpit view
- Changed the controls to x=shoot and c=camera
- Speed increase for each invaders destroyed
- The lasers are now separated so each one can live his proper life
- Added collision between lasers and walls
- Corrected laser aim thanks to Kjell

Aside from this page (http://zgameeditor.org/index.php/Compon ... rParticles) and the Particles.zgeproj example, are there some docs or tuto that explains how particles works ?
Attachments
TINStarfox.zip
TINStarfox 0.0.2
(39.61 KiB) Downloaded 1007 times
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Ats,
Ats wrote:Aside from this page (http://zgameeditor.org/index.php/Compon ... rParticles) and the Particles.zgeproj example, are there some docs or tuto that explains how particles works ?
The RenderParticles component is quite straight-forward actually, but here is a video you can follow along to get you started :wink: Keep in mind that the component is for 2D particles only at the moment .. even though you can move it around in 3D.

+ Nice progress on your project ~

@Ville - Could you please correct the timing of the RenderParticles component? For example, when the interval is 2 ms and a frame has taken 3 ms, it shouldn't spawn at the origin, but at 1/3ms worth the initial velocity.

K
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Thanks again Kjell, it's very easy to understand how particles works following that super secret video ;)

So here is the new version, and it's beginning to take shape !

- Smoother controls
- Separated wings from the ship with their own collision box
- Added vertex Color to the ship
- Added S and D key to roll the ship
- Added i key for debug informations
- Added turbulence
- The ship bounces when it is hit
- The ship now rotates on the 3 axes
- Added explosions particles
- Added Hull dammage. Game Over at 100%

And yet again, I have some questions. Let's start with the one that badly surprised me...
Why the collision boxes are not rotating with their model ???
Is there a way to make that happen ?
Attachments
TINStarfox.zip
TINStarfox 0.0.3
(42.8 KiB) Downloaded 1015 times
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:?
Ats wrote:Why the collision boxes are not rotating with their model ??? Is there a way to make that happen ?
I knew that question was coming .. there isn't no ( since there is no Box3D_OBB collision style ).

What would you be using a Box collider for though? To check for collision between the Arwing & enemies / environment?

K
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

The problem is that when you roll with s or d key, the wings collision boxes stays on the left and right sides. I need them on the top and bottom... If there are no options for that, I think I can add some collision boxes around the ship by attaching some models to it, and then only test the colission boxes that matches to the ship roll angle.

Something like that (behind view):

UL U UR
L ship R
DL D DR

For example, when the ship is +/-45° going to the right, I'm only testing collision on UL and DR. I think that would works...

I have one more question: Right now, the shadow is obviously a fake one, using a flat ship on the Y axe and playing with his X scale. While it was good when the ship was not turning too much, it has become quite poor since the ship can now roll up to 90°... And the "barrel rolls" are coming for the next version !

So, can the light calculate shadows ? Or can I flatten the ship on the Y world axe and not on his own Y axe after his rotation ? Some kind of projection thingy I guess... It's my first game in 3D... I can imagine some tricks but maybe you can help me with better solutions :)
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Ats,
Ats wrote:The problem is that when you roll with s or d key, the wings collision boxes stays on the left and right sides.
The reason I asked is because a box isn't exactly the ideal collision shape for a Arwing. Normally you'd want to use mesh-based collision ( or shoot a couple of rays along the wing-edges if you want to be cheap ), which isn't build-in either .. so you'll have to do some calculations regardless :(
Ats wrote:So, can the light calculate shadows ? Or can I flatten the ship on the Y world axe and not on his own Y axe after his rotation ? Some kind of projection thingy I guess... It's my first game in 3D... I can imagine some tricks but maybe you can help me with better solutions :)
You can do either. ZGameEditor has a RenderTarget component which you can use as a shadow-map, but the flatten-trick is easier .. see attached for a example.

K
Attachments
Shadow.zgeproj
(1.27 KiB) Downloaded 1129 times
User avatar
Ats
Posts: 713
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

Thanks again ;)

While trying to understand what's happening in your exemple, I came upon what I beleive to be an error in the ComponentRef pages for RenderTransform and RenderTransformGroup. Instead of "Transform", the property should be "Translate".

Calculating a mesh based collision is way above my current skills. I'll find a cheap solution until then !
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Ats,
Ats wrote:Calculating a mesh based collision is way above my current skills. I'll find a cheap solution until then !
If you're going for a cheap solution I'd suggest using a couple of collision "nodes". This does however require you to calculate the position of the nodes relative to the Arwing .. so attached is another example :wink:
Ats wrote:While trying to understand what's happening in your exemple, I came upon what I beleive to be an error in the ComponentRef pages for RenderTransform and RenderTransformGroup. Instead of "Transform", the property should be "Translate".
You're right, should be Translate instead of Transform ~

K
Attachments
Nodes.zgeproj
(2.96 KiB) Downloaded 1172 times
Post Reply