Forum Replies Created
- 
		AuthorPosts
 - 
		
			
				
August 25, 2016 at 10:51 am in reply to: FPS, Delta, FixedFPS, Timing, Animation Topic (almost done) #3445
ignore the fixed timing strategy
I was searching for the ‘best’ possible solution to make my app things running at the same speed on all ios/android/desktop (full screen/windowed).
In the weekend i’m going back to basic delta timing.
Maybe if I publish a game in the future, I will add something like this:
System requirements:
– Screen device must run at 60hz and the OS must have enabled vsync.Just to make sure I don’t get any/(less) sad/mad customers.
August 25, 2016 at 8:14 am in reply to: FPS, Delta, FixedFPS, Timing, Animation Topic (almost done) #3439I would start with looking at the games included in the bananas folder of monkey2.
None use a timer and all expect OnRender to be called at 60hz as Window.SwapInterval defaults to 1 which means App.RequestRender causes subsequent OnRender to be correctly frame synced.
I will remove all the code, and see what happen.
I know about the bananas folder, I did see it, but I thought that maybe the creators din’t care about creating it.
But when I remove all the ‘timing’ code, I still need to use delta calculation or not ?
Is MX2 withSwapInterval=1 do all the things so I don’t need to care of delta anymore ?- Why not default SwapInterval=1 inside MX2 so beginners don’t have to know/ try to learn about those things.</span>
 
August 24, 2016 at 1:41 pm in reply to: FPS, Delta, FixedFPS, Timing, Animation Topic (almost done) #340860, 30 I don’t ‘care’ what it is haha because I don’t know what i’m doing/must do at this most important thing :S
Are those facts true ?
– MX is running at unlimited random frames a second.
– I need to call every 60 screenframe OnUpdate()I can drop that FixedLogicFPS because I don’t know if its better than something like below.
I was hoping that that there was one ‘template’ script that covers it all, so every programmer can start program.
Monkey1234567891011121314151617181920212223242526272829303132333435#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowGlobal counter:IntGlobal timer:TimerMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )canvas.DrawText( "Ticks : "+counter+" "+Millisecs(),Width/2,Height/2+50,.5,.5 )EndMethod New()timer=New Timer(60,OnUpdate) ' 60 ????EndMethod OnUpdate()Print "tock..." + countercounter=counter+1EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndIf there was only one drawing/moving animation script that is working on the same speed on every mid-range desktop/ios/android.
By drawing I mean:
– animation multiple image frames, (can set the duration each frame in MS)By moving I mean:
– the frame animation moving from point A to B– And later in the future collision will be added.
August 24, 2016 at 11:44 am in reply to: FPS, Delta, FixedFPS, Timing, Animation Topic (almost done) #3399I think I have it now, but not sure because its hard to understand this part of game making
Here is a video
There is only a problem when starting a game, you can see it in the beginning of the ‘movie’
The movement is way to fast, and after 1 or 2 seconds the Logic FPS is oke (100)The first animation is 1 second
oFS.frames.Add(New Frame(“1.jpg”,10000))
I want to use MS each frame, but I thought 1000 MS is 1 second (not 10000)The second frame is moving and the animation speed is
oFS.frames.Add(New Frame(“1.jpg”,500))The third frame is moving and the animation speed is
oFS.frames.Add(New Frame(“15.jpg”,60))If I understand it correctly, this means
New FixedRateLogicTimer(100.0, 20)Call Method OnUpdateGameLogic(_delta:Float) after every 100 frames.
AND everything inside that method don’t have to use speed*delta movement because this will happen every 100 frames (locked)Inside that OnUpdateGameLogic() I call the UpdateFrameTimer() to update the current frame duration like this.
Monkey1234567891011Method UpdateFrameTimer:Void(_delta:Float)If GameTime.newTime > timer + CurrentFrame().durationcurrFrameKey+=1If currFrameKey > frameEndcurrFrameKey = 0Endtimer = Millisecs()CurrentFrame().duration += 1*_deltaEndEndFull code
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335#Import "<std>"#Import "<mojo>"#Import "assets/animation/1.jpg"#Import "assets/animation/2.jpg"#Import "assets/animation/3.jpg"#Import "assets/animation/4.jpg"#Import "assets/animation/5.jpg"#Import "assets/animation/6.jpg"#Import "assets/animation/7.jpg"#Import "assets/animation/8.jpg"#Import "assets/animation/9.jpg"#Import "assets/animation/10.jpg"#Import "assets/animation/11.jpg"#Import "assets/animation/12.jpg"#Import "assets/animation/13.jpg"#Import "assets/animation/14.jpg"#Import "assets/animation/15.jpg"#Import "assets/animation/16.jpg"Using std..Using mojo..Global GameTime:FixedRateLogicTimer = New FixedRateLogicTimer(100.0, 20)#rem monkeydocALPHA TEST CODE, WITHOUT ALL THE CLASSES AND OTHER THINGS.Problem- At the start, the FPS is not 'correct' and the [FrameSet] movement is to fastQuestions- Is the timing correct, [Frame] duration drawing ?- Is this stable on mid-range/fast IOS/Android/Desktop ?- movement*_delta in OnUpdateGameLogic not working or not necessary ?The engine is something like this- 1 [scene]- contains 0:n [FrameSet]- contains 1:n [Frame][FrameSet]- If it contains >1 [Frame] then its a animation, using duration- If it contains 1 [Frame] then its not a animation[Frame]- A single image with optional a duration#endClass MyWindow Extends WindowField frameSets:Stack<FrameSet> = New Stack<FrameSet>()Method New( )SwapInterval=1 ' vsync' this part is normaly using loaded using json and 1 atlas file' ==========================================frameSets.Add(New FrameSet())Local oFS:FrameSet = frameSets.Get(0)oFS.frames.Add(New Frame("1.jpg",60))oFS.frames.Add(New Frame("2.jpg",60))oFS.frames.Add(New Frame("3.jpg",60))oFS.frames.Add(New Frame("4.jpg",60))oFS.frames.Add(New Frame("5.jpg",60))oFS.frames.Add(New Frame("6.jpg",60))oFS.frames.Add(New Frame("7.jpg",60))oFS.frames.Add(New Frame("8.jpg",60))oFS.frames.Add(New Frame("9.jpg",60))oFS.frames.Add(New Frame("10.jpg",60))oFS.frames.Add(New Frame("11.jpg",60))oFS.frames.Add(New Frame("12.jpg",60))oFS.frames.Add(New Frame("13.jpg",60))oFS.frames.Add(New Frame("14.jpg",60))oFS.frames.Add(New Frame("15.jpg",60))oFS.frames.Add(New Frame("16.jpg",60))oFS.frameEnd = oFS.frames.Length-1oFS.Position = New Vec2f( 400,400 )oFS.move2left = True' another framesetframeSets.Add(New FrameSet())oFS = frameSets.Get(1) ' another framesetoFS.frames.Add(New Frame("1.jpg",500))oFS.frames.Add(New Frame("2.jpg",500))oFS.frames.Add(New Frame("3.jpg",500))oFS.frames.Add(New Frame("4.jpg",500))oFS.frames.Add(New Frame("5.jpg",500))oFS.frames.Add(New Frame("6.jpg",500))oFS.frames.Add(New Frame("7.jpg",500))oFS.frames.Add(New Frame("8.jpg",500))oFS.frames.Add(New Frame("9.jpg",500))oFS.frames.Add(New Frame("10.jpg",500))oFS.frames.Add(New Frame("11.jpg",500))oFS.frames.Add(New Frame("12.jpg",500))oFS.frames.Add(New Frame("13.jpg",500))oFS.frames.Add(New Frame("14.jpg",500))oFS.frames.Add(New Frame("15.jpg",500))oFS.frames.Add(New Frame("16.jpg",500))oFS.frameEnd = oFS.frames.Length-1oFS.Position = New Vec2f( 400,250 )oFS.move2left = True' another framesetframeSets.Add(New FrameSet())oFS = frameSets.Get(2)oFS.frames.Add(New Frame("1.jpg",10000))oFS.frames.Add(New Frame("2.jpg",10000))oFS.frames.Add(New Frame("3.jpg",10000))oFS.frames.Add(New Frame("4.jpg",10000))oFS.frames.Add(New Frame("5.jpg",10000))oFS.frames.Add(New Frame("6.jpg",10000))oFS.frames.Add(New Frame("7.jpg",10000))oFS.frames.Add(New Frame("8.jpg",10000))oFS.frames.Add(New Frame("9.jpg",10000))oFS.frames.Add(New Frame("10.jpg",10000))oFS.frames.Add(New Frame("11.jpg",10000))oFS.frames.Add(New Frame("12.jpg",10000))oFS.frames.Add(New Frame("13.jpg",10000))oFS.frames.Add(New Frame("14.jpg",10000))oFS.frames.Add(New Frame("15.jpg",10000))oFS.frames.Add(New Frame("16.jpg",10000))oFS.frameEnd = oFS.frames.Length-1oFS.Position = New Vec2f( 200,100 )' ==========================================EndMethod OnRender( canvas:Canvas ) Overridecanvas.TextureFilteringEnabled=FalseApp.RequestRender()GameTime.ShowFPS(0, 0, canvas)Local delta:Float = GameTime.ProcessTime()While GameTime.LogicUpdateRequired()OnUpdateGameLogic(delta)EndLocal tween:Float = GameTime.GetTween()OnRenderGame(canvas)EndMethod OnUpdateGameLogic(_delta:Float)For Local oFS:FrameSet = Eachin frameSetsoFS.UpdateFrameTimer(_delta)If oFS.move2leftoFS.Position.x-=1If oFS.Position.x <= 50oFS.move2left = FalseoFS.move2right = TrueEndElseif oFS.move2rightoFS.Position.x+=1If oFS.Position.x >= 450oFS.move2left = TrueoFS.move2right = FalseEndEndNextEndMethod OnRenderGame(canvas:Canvas)For Local oFS:FrameSet = Eachin frameSetsoFS.Draw(canvas)NextEndEndClass FrameSetField frames:Stack<Frame> = New Stack<Frame>()Field currFrameKey:Int = 0Field timer:IntField frameEnd:IntField Position:=New Vec2fField move2left:Bool ' debugField move2right:Bool ' debugMethod New()EndMethod CurrentFrame:Frame()Return frames.Get(currFrameKey)EndMethod UpdateFrameTimer:Void(_delta:Float)If GameTime.newTime > timer + CurrentFrame().durationcurrFrameKey+=1If currFrameKey > frameEndcurrFrameKey = 0Endtimer = Millisecs()CurrentFrame().duration += 1*_deltaEndEndMethod Draw:Void(canvas:Canvas)canvas.DrawImage(CurrentFrame().img,Position.X,Position.Y)EndEnd ClassClass FrameField duration:IntField name:StringField img:ImageMethod New (_name:String,_duration:Int)name= _nameduration = GameTime.CalcFrameTime(_duration)img=Image.Load( "asset::"+_name)img.Handle=New Vec2f( .5,.5 )EndEnd ClassClass FixedRateLogicTimerField newTime:Double = Millisecs()Field oldTime:Double = Millisecs()Field delta:FloatField dssOn:Int ' do we use delta spike suppression?Field dssIndex:Int ' index into DSS_Array where next delta value is writtenField dssArray:Float[] ' this array contains the delta values to smoothField dssLenArray:Int ' how big is the array of delta valuesField logicFPS:FloatField accumulator:Float, tween:FloatField fpsAccumulator:FloatField updateCount:IntField renderCount:IntField updatesPerSecond:IntField rendersPerSecond:IntMethod New(logicCyclesPerSecond:Float, numSamples:Int = 0)logicFPS = 1.0 / logicCyclesPerSecond' Print "logicFPS = " + logicFPSIf numSamplesdssOn = TruedssArray = New Float[numSamples]dssLenArray = numSamplesEndEndMethod ProcessTime:Float()newTime = Millisecs()delta = Float (newTime - oldTime) * 0.001oldTime = newTimeIf dssOndssArray[dssIndex] = deltaLocal smoothDelta:Float = 0For Local i:Int = 0 To dssLenArray - 1smoothDelta += dssArray[i]Nextdelta = Float(smoothDelta / dssLenArray)dssIndex += 1If dssIndex > dssLenArray - 1 Then dssIndex = 0Endaccumulator += deltafpsAccumulator += deltaIf fpsAccumulator > 1.0fpsAccumulator -= 1.0updatesPerSecond = updateCountupdateCount = 0rendersPerSecond = renderCountrenderCount = 0EndReturn deltaEndMethod LogicUpdateRequired:Int()If accumulator > logicFPSupdateCount += 1accumulator -= logicFPSReturn TrueEndReturn FalseEndMethod GetLogicFPS:Float()Return logicFPSEndMethod GetTween:Float()renderCount += 1Return accumulator / logicFPSEndMethod CalcFrameTime:Float(ms:Int)Return ms / 1000.0 / (logicFPS / 1.0)EndMethod ShowSpikeSuppression(x:Int, y:Int, canvas:Canvas)canvas.DrawText("Delta Spike Suppressor:", x, y)canvas.DrawText("Final Delta: " + delta, x, y + 20)EndMethod ShowFPS(x:Int, y:Int, canvas:Canvas, showUpdateFPS:Int = True, showRenderFPS:Int = True)Local ty:Int = yIf showUpdateFPScanvas.DrawText("Logic FPS: " + updatesPerSecond, x, ty)ty += 20EndIf showRenderFPScanvas.DrawText("Render FPS: " + rendersPerSecond, x, ty)EndEndEndFunction Main()New AppInstanceNew MyWindow()App.Run()EndAugust 24, 2016 at 6:55 am in reply to: FPS, Delta, FixedFPS, Timing, Animation Topic (almost done) #3393Created new topic below
August 19, 2016 at 9:24 am in reply to: Ted2 1.0.3 crashes when trying to open a file on W10 and W7 #3216For me its Oké that the app Help files are generated inside the app root folder (Help). Or in the root build folder.
That would be cool to get some overview.
for the modules I don’t know.
for your own made app I asked here
http://monkey2.monkey-x.com/forums/topic/make-docs-for-your-own-app-not-a-module/No I was hoping that it was possible. Because a app looks like a module .
Maybe its a Small thing for Mark to make.
I’m wondering if there are some Atlas restrictions like grapimage have.
These are.
Multiple frame images are assumed to be laid out in a horizontal strip, in which case width and height are the dimensions of each frame, and the source image must be wide enough to contain the entire strip.
Note that if image flags includes any padding, then the specified rectangle includes padding. This means image width and/or height may be ‘2 less’ than the width and/or height you specify.For New Image(img,recti(x,y,x2,y2))
Because I get some weird things using a new spritesheet Atlas creator.
I guess that all sort of Atlas image formats are now allowed , and no 1px padding is needed anymore ?
Usefull information for others.
No AdamStrang,
You asked for a code that crashes ted21 editor, so that’s why I gave you that code.
I know how to solve that error in that script I gave you, because I asked that here a week ago.
http://monkey2.monkey-x.com/forums/topic/new-vec2f-not-working-inside-new-constructor/Ted21 crashes the second time when I run a “error generated script” after not stopping the debug process (red button, in debug view) first.
Even when you use debugStop() in a good working script.
I test it now it the original ted2 and it does the same.
and a other situation
run a non error program and use DebugStop() to stop the program.
after that press the red button in the topbar (next debug).then remove the DebugStop() AND don’t press the stop button in the debug view.
Now run debug run again, and ted21 crashes, the result is the same as above topic.this won’t happen if I do press the stop button in the debug window.
So I assume to fix this bug, is to run that action before running a new debug run
Step 1 start on osx ted21
Copy / past / save this error generated codeMonkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New()Local FrameSetCollection:StringMap<FrameSet> = New StringMap<FrameSet>()Local player:Player = New Player(FrameSetCollection, "Bla", 200, 300)EndMethod OnRender( canvas:Canvas ) Overridecanvas.DrawText( "Hello World",Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndClass FrameSetField Position:= New Vec2fField Vector:= New Vector()Method Move:Void(_mx:Float, _my:Float)' Print _mx' Print _my' HERE IS THE ERROR, CREATING NEW VEC2F''Position=New Vec2f' Vector.x = 2' Vector.Set(3)' Position = New Vec2f(_mx,_my)EndEnd ClassClass SpriteField FrameSetCollection:StringMap<FrameSet>Field FrameSetColKey:StringMethod New(_FrameSetCollection:StringMap<FrameSet>,_FrameSetColKey:String)FrameSetCollection = _FrameSetCollectionFrameSetColKey = _FrameSetColKey' FrameSetCollection.Add(FrameSetColKey, New FrameSet)EndEnd ClassClass VectorField x:FloatMethod Set(_x:Float)x= _xEndEnd ClassClass Player Extends SpriteMethod New(_FrameSetCollection:StringMap<FrameSet>,_FrameSetColKey:String,_initX:Float,_initY:Float)Super.New(_FrameSetCollection,_FrameSetColKey)_FrameSetCollection.Get(_FrameSetColKey).Move(_initX,_initY)EndEnd ClassDebug run it.
Then the program hangs, press the red stop button.
Ted21 is now still alive, and the program is stopped.Then press again Debug run.
Ted21 crashes now (quits) and the program hangs again (manual force quit in osx)
This is with all memory generated errors.
This is on my macbook air (latest osx) and (iMac)
I will try to create a file this week for you.
nope its still crashes after a program hang -> then stop the program -> and re-run the program -> ted21 crash
but i’m used to it
 - 
		AuthorPosts