- Joined
- Jan 2, 2020
- Messages
- 569
I've got a related question today.
Got the local .json file access working (am also very happy that Cerberus includes a json class, this save me a lot of time writing json code!).
What if you want to cut the middleman and instead now you want to load and save the data using a https server? This will be very a very important for highscores so I thought I'd better look into this before I choose the toolset that will be needed to create the whole game.
I've checked the documentation the whole day and I found that fileStream is used for files while Sockets seems to be the one for the web.I want to stay clear from TCPstream.
This is the local version which will be my base for downloading (and eventually uploading) a json file from a HTTPS server.
Got the local .json file access working (am also very happy that Cerberus includes a json class, this save me a lot of time writing json code!).
What if you want to cut the middleman and instead now you want to load and save the data using a https server? This will be very a very important for highscores so I thought I'd better look into this before I choose the toolset that will be needed to create the whole game.
I've checked the documentation the whole day and I found that fileStream is used for files while Sockets seems to be the one for the web.I want to stay clear from TCPstream.
This is the local version which will be my base for downloading (and eventually uploading) a json file from a HTTPS server.
code_language.cerberus:
Strict
Import mojo2
Import brl.filestream
Import os
Function Main:Int()
New Game()
Return 0
End
Class Game Extends App
Field canvas:Canvas
Method OnCreate:Int()
canvas=New Canvas
canvas.Clear
' Create data
Local numbers:Int[] = [10,20,30,40,50,60,70,80,90,100]
' Find directory
Local exeRoot := RealPath(ExtractDir(AppPath()))
Local besideapp := RealPath(exeRoot+"/../../../")
' Save data
Local dump := New FileStream(besideapp+"/"+"numbers.dat","w")
For Local i:Int = EachIn numbers
dump.WriteString(i+ ",") ' as (8-bit) strings, totally 31 bytes.
' dump.WriteInt(i) ' as (32-bit) integers, totally 40 bytes.
Next
dump.Close
Return 0
End
Method OnRender:Int()
' DebugStop
Return 0
End
End