Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Code] Saving media into an array

Author
Message
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 23rd Mar 2017 23:40 Edited at: 24th Mar 2017 00:03






Hello friends,

I have some functions I wanted to share.


This code creates a Textfile with an array based on the input file. The array name can also be defined:

For example: copyFileByte("music.ogg", "music_array.txt","Music1")

Create array from media:


This function call creates a textfile "music_array.txt" with a copy-paste code of an integer array with the name "Music1". If you add this code to an AppGameKit project,
you can read it out like this: msc = LoadMusicFromArray( Music1 )

Read from array:



I have also attached an example project with an old music that I made:
https://forum.thegamecreators.com/attachment/78924



So this code helps you to save small pieces of media inside an array,
you can save anything you like in it. It works with images, 3d models, sound, music.
You can use this functions to hide your media, although the representation in strings
instead of integers (like I did) could reduce the total size to 50%, so there is still a lot of potential in this idea.
If you want to use this heavily, add each Array into one seperate include file, this will still be compiled into the bytecode,
but a lot of chars in a textfile can reduce your editing-speed, so paste this arrays in a seperate include file for maximum performance.


I hope it's useful for someone.

Greetings,
Jack

[/url]

Attachments

Login to view attachments
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Apr 2017 17:57
This is a nice idea - one I've used in the past for my media control system.

I used to use this method with freebasic back in the day and I made a tool that generated the data statements out of binary files which you just included into your main executable.

Login to post a reply

Server time is: 2024-04-20 11:27:37
Your offset time is: 2024-04-20 11:27:37