Forum Replies Created
- 
		AuthorPosts
 - 
		
			
				
Update…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127Namespace rpgf#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class TypewriteTextClass LineField text:StringField count:IntMethod New:Void(text:String)Self.text = textEndEndProtectedField lines:List<Line>Field timer:TimerField currentLine:IntPublicMethod New:Void()lines = New List<Line>()EndMethod AddLine:Void(text:String)If Not (text.Contains("\n"))lines.AddLast(New Line(text))ElseLocal textArray:String[] = text.Split("\n")Local textArrayLength:Int = textArray.LengthLocal i:Int = 0For i = 0 Until textArrayLengthlines.AddLast(New Line(textArray[i]))NextEndEndMethod SetTimer:Void(seconds:Double)timer = New Timer(seconds, Update)timer.Suspended = TrueEndMethod Draw:Void(canvas:Canvas, x:Float, y:Float)timer.Suspended = FalseLocal allLines:Line[] = lines.ToArray()Local i:Int = 0Local currentLineTemp:Int = 0For i = 0 Until allLines.Lengthcanvas.DrawText(allLines[i].text.Left(allLines[i].count), x, y + (canvas.Font.Height * i))NextEndProtectedMethod Update:Void()timer.Suspended = FalseLocal allLines:Line[] = lines.ToArray()allLines[currentLine].count += 1If (allLines[currentLine].count > allLines[currentLine].text.Length)currentLine += 1EndIf (currentLine >= lines.Count())currentLine = lines.Count() - 1EndEndEndClass MainWindow Extends WindowField targetFps:TimerField typewriteText:TypewriteTextMethod OnMeasure:Vec2i() OverrideReturn New Vec2i(320, 240)EndMethod New:Void()Super.New("RPG-Framework", 640, 480, WindowFlags.Center)Layout = "letterbox"targetFps = New Timer(60, OnUpdate)typewriteText = New TypewriteText()' typewriteText.AddLine("First line...")' typewriteText.AddLine("Second line...")' typewriteText.AddLine("Third line...")' typewriteText.AddLine("Fourth line...")' typewriteText.AddLine("Fifith line.")' typewriteText.AddLine("....................")typewriteText.AddLine("First line...\nSecond line...\nThird line...\nFourth line...\nFifith line.\n....................")typewriteText.SetTimer(30)EndMethod OnUpdate:Void()App.RequestRender()If (Keyboard.KeyHit(Key.Escape))App.Terminate()EndEndMethod OnRender( canvas:Canvas ) Override' App.RequestRender()canvas.TextureFilteringEnabled = Falsecanvas.Clear(Color.Black)canvas.Color = Color.WhitetypewriteText.Draw(canvas, 0, 0)canvas.Color = Color.Whitecanvas.DrawText("FPS: ", 320 - 60, 0)canvas.Color = Color.Redcanvas.DrawText("" + App.FPS, 320 - 60 + canvas.Font.TextWidth("FPS: "), 0)EndEndFunction Main:Void()New AppInstance()New MainWindow()App.Run()EndMonkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127Namespace rpgf#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class TypewriteTextClass LineField text:StringField count:IntMethod New:Void(text:String)Self.text = textEndEndProtectedField lines:List<Line>Field timer:TimerField currentLine:IntPublicMethod New:Void()lines = New List<Line>()EndMethod AddLine:Void(text:String)If Not (text.Contains("\n"))lines.AddLast(New Line(text))ElseLocal textArray:String[] = text.Split("\n")Local textArrayLength:Int = textArray.LengthLocal i:Int = 0For i = 0 Until textArrayLengthlines.AddLast(New Line(textArray[i]))NextEndEndMethod SetTimer:Void(seconds:Double)timer = New Timer(seconds, Update)timer.Suspended = TrueEndMethod Draw:Void(canvas:Canvas, x:Float, y:Float)timer.Suspended = FalseLocal allLines:Line[] = lines.ToArray()Local i:Int = 0Local currentLineTemp:Int = 0For i = 0 Until allLines.Lengthcanvas.DrawText(allLines[i].text.Left(allLines[i].count), x, y + (canvas.Font.Height * i))NextEndProtectedMethod Update:Void()timer.Suspended = FalseLocal allLines:Line[] = lines.ToArray()allLines[currentLine].count += 1If (allLines[currentLine].count > allLines[currentLine].text.Length)currentLine += 1EndIf (currentLine >= lines.Count())currentLine = lines.Count() - 1EndEndEndClass MainWindow Extends WindowField targetFps:TimerField typewriteText:TypewriteTextMethod OnMeasure:Vec2i() OverrideReturn New Vec2i(320, 240)EndMethod New:Void()Super.New("RPG-Framework", 640, 480, WindowFlags.Center)Layout = "letterbox"targetFps = New Timer(60, OnUpdate)typewriteText = New TypewriteText()' typewriteText.AddLine("First line...")' typewriteText.AddLine("Second line...")' typewriteText.AddLine("Third line...")' typewriteText.AddLine("Fourth line...")' typewriteText.AddLine("Fifith line.")' typewriteText.AddLine("....................")typewriteText.AddLine("First line...\nSecond line...\nThird line...\nFourth line...\nFifith line.\n....................")typewriteText.SetTimer(30)EndMethod OnUpdate:Void()App.RequestRender()If (Keyboard.KeyHit(Key.Escape))App.Terminate()EndEndMethod OnRender( canvas:Canvas ) Override' App.RequestRender()canvas.TextureFilteringEnabled = Falsecanvas.Clear(Color.Black)canvas.Color = Color.WhitetypewriteText.Draw(canvas, 0, 0)canvas.Color = Color.Whitecanvas.DrawText("FPS: ", 320 - 60, 0)canvas.Color = Color.Redcanvas.DrawText("" + App.FPS, 320 - 60 + canvas.Font.TextWidth("FPS: "), 0)EndEndFunction Main:Void()New AppInstance()New MainWindow()App.Run()EndProblem solved. I did the whole compilation process again, and made a change to the Desktop name (it was translated to Pt-Br). Maybe it was causing a directory error, where ‘ted2’ could not find the compiler path.
Hey Mark … Now I understand how it works. I spent the day looking at all the forum posts related to Mojox, and it opened my mind more. I’m still confused about some things, but I understand their operation much more.
I’ll keep doing my tests here. And once again, thank you for your help.
Thank you Mark. (Now I’ve opened my vision a little more, but it’s still confusing …).
Taking advantage of the hook, I also miss out on how the coordinates of the GUI components on the screen work.
In BlitzMax, he used the x, y coordinates. I still try to understand how the organization works in Monkey 2.
Could you give me a brief explanation of how it works?
Note: I have already looked at all the examples and still I still do not understand very well.
Error sending the compressed file. Send the link to download.
ps: To make it easier and not have to copy and paste these files in all projects, just copy to the folder: c:\monkey2-v1.1.09\products\android\monkey2game\ which, when generating the build for Android, automatically copied these files to the project folder.
https://drive.google.com/open?id=1i7gLUzfiHFqbbEqkeuz_flmO2JU_glOF
I got lucky, Mark. I saved the files that are generated when I opened the project in Android Studio. Yesterday I did an update on it, so I was not compiling anymore, because I updated Gradle along with Android SDKs.
I just copied the files I got from the Gradlew backup and compiled without major problems.
Attached is the necessary files. Just copy it to the project folder and compile it. In my case: demo.products\Android\….
I can not return a value of type Bool inside a JsonArray, but outside it everything happens. I’ve worked around this problem, reading the String and storing its value in a variable of type Int. Ex: if the String is False, it returns 0, if not, it returns 1. Then, in the end, it ended up being a type variable Int (which does not change at all at the time of use).
The library already imports the almost complete map, including: tile layer, objects (which can contain: lines, polygons …). Missing part of the animations and some extras.
I spent that time without pounding it, but now I’m back and I’m going to redo so I can make the necessary optimizations. There is a high memory consumption depending on the size of the images and the amount of Tiles per layer.
Soon, I will send the link of the “final” version here in the forum.
I get the following error:
Mx2cc version 1.1.06
***** Making module ‘assimp’ *****
Parsing…
Semanting…
Translating…
Compiling…
gzclose.c
c:\monkey2-v1.1.06\modules\assimp\assimp\contrib\zlib\gzguts.h(29): fatal error C1083: Cannot open include file: ‘unistd.h’: No such file or directory
Build error: System command ‘cl -c -EHs -W0 -MT -Ox -DNDEBUG -I”C:/Monkey2-v1.1.06/modules/” -I”C:/Monkey2-v1.1.06/modules/monkey/native” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/include/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/code/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/unzip/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/irrXML/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/rapidjson/include/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/openddlparser/include/” -Fo”C:/Monkey2-v1.1.06/modules/assimp/assimp.buildv1.1.06/windows_release_msvc/build/_1_1_1assimp_2contrib_2zlib_2gzclose.c.obj” “C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/zlib/gzclose.c”‘ failed.cl -c -EHs -W0 -MT -Ox -DNDEBUG -I”C:/Monkey2-v1.1.06/modules/” -I”C:/Monkey2-v1.1.06/modules/monkey/native” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/include/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/code/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/unzip/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/irrXML/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/rapidjson/include/” -I”C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/openddlparser/include/” -Fo”C:/Monkey2-v1.1.06/modules/assimp/assimp.buildv1.1.06/windows_release_msvc/build/_1_1_1assimp_2contrib_2zlib_2gzclose.c.obj” “C:/Monkey2-v1.1.06/modules/assimp/assimp/contrib/zlib/gzclose.c”
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
***** Fatal mx2cc error *****
Internal mx2cc build error
Update modules failed.
Total time elapsed: 0 m 0 s.I’m still working on the Tiled Editor’s map interpreter. In this version, you can read custom properties of the map and each layer individually.
Note: You can only read values of the following types: Bool, Float, Int and String (for now).
A highlight for type Bool: Using the Map class, I could not read the correct Bool type, which always returns False. Then, I saved as Int (0 = False, 1 = True). Outside the Map, saving in any variable, the Bool value is correct. If anyone has a solution, I’ll make the correction.
Otherwise, the class is fully usable. Now I will worlk on the objects and the object layer, and the on the animations of the tiles.
https://drive.google.com/open?id=0B2lZ_pN3kwOJZlF2YU5qd29QdTQ
I understand that question. Thanks ‘nerobot’.
It would be the same as:
Monkey123If (layers[layerId].map[x, y] > -1)' DrawEndNow you have a part that I do not understand. In the map matrix, the value -1 corresponds to no tiles, that is, no tiles with this value will be rendered, just above it.
I saw above, what you did:
Monkey1If layers[layerId].map[x, y] = -1 Continue. I think that this way, it should render the tiles only value -1… What whould be the logic behind?
abakobo, I followed your recommendations as well.
Did not quite understand. Would you have a simple example?
I’ve been trying to do some optimizations. I rendered a 1000×1000 map with 48×48 tiles and FPS in release mode averaged 10 FPS.
After the optimizations, I got the average between 55 and 60 FPS with the same gigantic map.
Below is the code. I would like opinions and know if I made a mistake.
Monkey1234567891011121314151617181920212223242526272829303132' BEFOREMethod Render(canvas:Canvas, layerId:Int)For Local y:Int = 0 Until layers[layerId].heightFor Local x:Int = 0 Until layers[layerId].widthIf (layers[layerId].map[x, y] > -1)Local tile:TiledTile = New TiledTile()tile.image = tileArray[layers[layerId].map[x, y]].imagetile.xy = New Vec2f(layers[layerId].x + x * tileWidth, layers[layerId].y + y * tileHeight)If (tile.xy.X > -tileWidth And tile.xy.X < canvas.Viewport.Width And tile.xy.Y > -tileHeight And tile.xy.Y < canvas.Viewport.Height)canvas.DrawImage(tile.image, tile.xy.X, tile.xy.Y)EndEndNextNextEnd' AFTERMethod Render(canvas:Canvas, layerId:Int)For Local y:Int = 0 Until layers[layerId].heightFor Local x:Int = 0 Until layers[layerId].widthIf (layers[layerId].map[x, y] > -1)Local xy:Vec2f = New Vec2f(layers[layerId].x + x * tileWidth, layers[layerId].y + y * tileHeight)If (xy.X > -tileWidth And xy.X < canvas.Viewport.Width And xy.Y > -tileHeight And xy.Y < canvas.Viewport.Height)Local tile:TiledTile = New TiledTile()tile.image = tileArray[layers[layerId].map[x, y]].imagetile.xy = xycanvas.DrawImage(tile.image, tile.xy.X, tile.xy.Y)EndEndNextNextEnd - 
		AuthorPosts