Page 1 of 1

"ZPong.zge" example needs fixing

Posted: Mon May 04, 2015 5:27 am
by rrTea
Here's what I noticed happens in the current build with one of the examples that comes bundled with ZGE...

As soon as the game is run, it starts to beep constantly.

Another thing is... it seems the MouseModelController component has a lag? You can see it in this example, the pink model is calculating its position by reading Mouse x and y directly and it works great, the other uses the MouseModelController and has a "touchscreen style" floaty / laggy / imprecise movement.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FrameRateStyle="2" FixedFrameRate="60" Camera="ProjectionFrontal" NoSound="1">
  <OnLoaded>
    <SpawnModel Model="Model1"/>
    <SpawnModel Model="Model2"/>
  </OnLoaded>
  <Content>
    <Material Name="ColorMono"/>
    <Model Name="Model1" Comment="Gets the coordinates by calculating them manually" Scale="0.5 0.5 1">
      <OnUpdate>
        <ZExpression>
          <Expression>
<![CDATA[CurrentModel.Position.X = App.MousePosition.X*App.ViewportWidth/App.ViewportHeight;
CurrentModel.Position.Y = App.MousePosition.Y;]]>
          </Expression>
        </ZExpression>
      </OnUpdate>
      <OnRender>
        <UseMaterial Material="ColorMono"/>
        <RenderSetColor Color="1 0 0.502 1"/>
        <RenderSprite/>
      </OnRender>
    </Model>
    <Model Name="Model2" Scale="0.5 0.5 1">
      <OnSpawn>
        <ZExpression Expression="Mover.ScaleX = 1f*App.ViewportWidth/App.ViewportHeight;"/>
      </OnSpawn>
      <OnUpdate>
        <MouseModelController Name="Mover" ScaleX="1" ScaleY="1"/>
      </OnUpdate>
      <OnRender>
        <UseMaterial Material="ColorMono"/>
        <RenderSetColor Color="0.502 0.502 1 1"/>
        <RenderSprite/>
      </OnRender>
    </Model>
    <Camera Name="ProjectionFrontal" Comment="No rotation, for interface etc" Kind="1" Position="0 0 10"/>
  </Content>
</ZApplication>

Posted: Mon May 04, 2015 7:43 am
by VilleK
Hi,

A beeping sound? I don't get that here. Can you try to locate what is causing it?

I kind of like the lag :). But indeed maybe the update logic should be changed to use an expression instead. I doubt the MouseModelController has ever been used anywhere except in this project. It is nice to have for simple movement though when you have preference for components over code.

Posted: Mon May 04, 2015 8:08 am
by rrTea
Just to confirm what's happening, here's what it sounds on my computer (attached). Or is this by design? I could swear it wasn't doing it the last time I saw it. Maybe I'm using an outdated file.

As for the MouseModelController - well I'm probably the biggest fan of using components on this forum, yet I'd probably avoid using it if it were like this... maybe it could have an "elasticity" / lag factor for people who like it?

Posted: Mon May 04, 2015 9:06 am
by VilleK
It is by design. There is a short sound triggered repeatedly when either of the players move. So if both bats are moving then there is a lot of sound. I guess I wanted to show off the realtime audio fx features (with delay etc) and kind of of overused it a bit ;)

Posted: Mon May 04, 2015 9:19 am
by rrTea
Oh... heh nevermind it then :) Well it does show the use of realtime audio fx.