Forum Replies Created
-
AuthorPosts
-
September 1, 2017 at 6:57 am in reply to: Fu***ng message " *** Forbidden. Message seems to be spam. *** " #10182Monkey1Worked. Cool! Will see.
Pseudocode:
Monkey12345678910111213141516Method Render(canvas:Canvas, layerId:Int)Local xStart := [calculate x-index for first visible tile accordingly to x-offset]Local yStart := [calculate y-index for first visible tile accordingly to y-offset]Local xEnd := xStart + viewport.width / tileWidthLocal yEnd := yStart + viewport.height / tileHeightFor Local y := yStart To yEndFor Local x := xStart To xEndIf layers[layerId].map[x, y] = -1 ContinueLocal xy:Vec2f = New Vec2f(layers[layerId].x + x * tileWidth, layers[layerId].y + y * tileHeight)Local image := tileArray[layers[layerId].map[x, y]].imagecanvas.DrawImage(image, xy.x, xy.y)NextNextEndNote:
- inside of FOR I removed check for visibility because now we go through visible tiles onle
- also I removed creating New TiledTile() – why to create instance if we can just draw ‘plain’ image
- also I replaced xy.X & xy.Y with xy.x & xy.y – because of access to fields (small chars here) is faster that to properties (properties equals to method call)
Working with constant-sized tiles grid you can calculate starting and ending indexies for x and y outside of double for-for.
Then your ‘for’ loops will go through visible tiles only.
Now hiding errors list when building modules.
September 1, 2017 at 2:56 am in reply to: Fu***ng message " *** Forbidden. Message seems to be spam. *** " #10171This post was blocked: https://pastebin.com/dGu4VM2S
Post’s formatting presented on screenshot – there are two code blocks.
Attachments:
Does this seem to make sense or dir I really make a mistake?
Using float for coords is OK.
My posts above just answering for your
and, like magic, the problem ended. I do not know if it’s a Monkey2 bug, but for me, that should not happen.
Answer is – there is no magic, it’s just a type conversion rules.
Right, and you got Float+UInt=Float types conversion. The only (one) Float in expression make whole result as Float.
And with float map get its negative coords.
The x and y found in: map[x, y], are UInt, since there is no image with id less than zero in the array.
yes, they are, but them “break” you expectation because of type conversion UInt+Int=UInt
Monkey1canvas.DrawImage(tileArray[layers[layerId].map[x, y]].image, layers[layerId].x + x * tileWidth, layers[layerId].y + y * tileHeight)The problem here is mixing UInt with Int.
When you sum int with uint you got uint which have non-negative value only.
If you replace all UInt with Int (including “for local x:uint = …”) your map will render normally.
There is no playable demo in archive – no images and map file. So I can’t test it.
(My advices about your code were eaten by antispam, even splitted by parts)
It totally depends on info given from mx2cc.
Looks like it take a portion of errors and can take more after we fixed current ones.
You are passing a class to scene not an instance of a class???
Just press F2 on ScreenManager and jump to declaration. You’ll see that
Monkey123Property ScreenManager:ScreenManager()Return _screenManagerEndyes! mx2 allow us naming variables the same as classes, so we can be surprised sometimes.
(this lang feature prevents me to do code jumping properly – especially in such cases)
Hm. Need to deep into canvas+image life. Quick look give me canvas’ constructor with argument type of Image. When we resize codemap – we must resize image, so our current canvas became invalid, and we need to create new one for our new image.
Canvas is a local variable here – it should be GC collected when exit from render – render occur only when textview has changes.
Image live until resize codemap – by moving / show / hide debug consoles.
EDIT: I tried to store canvas as field method and recreate only when image, have no appreciable effect.
Just read Hezkore’s bit – is the new codemap in ted2go master branch? If so I’ll pull it ASAP and include in the next release.
Yes. Current master is v2.5 with new codemap.
-
AuthorPosts
