• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help with Binary: "Splitting up" and "Putting Together" Numbers

T

ThunkGames

Guest
I am working on speeding up the loading in my sandbox game by reading and writing to and from binary files instead of text files.

I can use this code to "break down" an integer into bytes as to write them into binary files:

Code:
var b1 = int >> 24 & 255;
var b2 = int >> 16 & 255;
var b3 = int >> 8 & 255;
var b4 = int & 255;
But I don't know how to "put together" these 4 values after I read them.
 
B

bojack29

Guest
As icuurd said. I tried using text files for a paint editor I made some time ago. It saved the individual colours on the image 1 by 1. And these were million digit sized numbers (16,546,234). Text files worked but were incredibly slow. Using buffers instead increased the speed dramatically.
 
T

ThunkGames

Guest
b1<<24|b2<<16|b3<<8|b4

use the buffer write and buffer read system instead of binary files
Thank you very much. Load speeds for my game have been tripled. I had already been using buffers to store block data "in game", but needed to store unloaded chunks of data on the user's disk.
 
Top