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 / Reading and Writing data to and from a file

Author
Message
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 29th Jan 2015 02:35
Well anyone who can help it would be appreciated.
It doesn't matter what I do with AGK2 but I can't get to write to a file or read for that matter.
Some example codes below in the docs but it doesn't work.

There doesn't appear to be the file saved anywhere with the data in it???

Strange





Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C & C++ / now also AGK2! Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga. Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jan 2015 08:53 Edited at: 29th Jan 2015 08:54
Files created by AppGameKit apps are put in the "C:\Users\username\AppData\Local\AGKApps\appname\media" folder.

This is because windows requires you to write to a location that is not protected on none admin accounts.

AGK writes to other folders on other systems.

EDIT: Also if the file exists in the media folder and the AppData folder the AppData version will be read, so you can update the 'local' file without overwriting it this means if you use DeleteFile you can go back to the original file version which is very useful...


Using AppGameKit V2 Tier 1
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 29th Jan 2015 16:28
Thanks for the info, had a time finding the files as on my computer as they weren't showing at first but did a search and it appeared.
Now created a shortcut on my desktop to the folder to make things easier.

Windows!

Surely there is an easier way that should save to the actual folder where creating.

Will have a mess with these in a bit to see how they work.


Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C & C++ / now also AGK2! Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga. Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 29th Jan 2015 17:15
Hmmm, not sure about this yet but just tried creating a memBlock file from a 21Kb png image and the file is 3.5Mb in size!

Is this correct?

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C & C++ / now also AGK2! Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga. Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jan 2015 17:29
Quote: "Surely there is an easier way that should save to the actual folder where creating."


You need to consider that your games may be installed on another person's computer, and they won't take kindly to you overriding their security. From Windows Vista onwards, it's not allowed to update/write to Program Files under standard permissions.

Quote: "Hmmm, not sure about this yet but just tried creating a memBlock file from a 21Kb png image and the file is 3.5Mb in size!"


It all depends on the image content. PNG files are compressed. So a 256x256 PNG is 1.65KB. A 256x256 Bitmap - which is very close to the memblock format - is 256KB in size.

You can work out the memblock size of an image:

12 + (height * width * 4) bytes

Quidquid latine dictum sit, altum sonatur
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 29th Jan 2015 17:34
Well just had a look at other methods of writing too eg WriteLine and Write String and when I do the math it is correct. See below:

Picture is 1150 x 800 png file size is 21kb

1150 x 800 x 4 bytes per pixel = 3680000 bytes = 3.68Mb


I was thinking of using a method like this to save reading pixel data in the game I am doing to save time but will have to check speed dif to see if the extra file size is actually an advantage.

Reading each pixel in a memBlock to a 2D array or reading the saved information from that memBlock from a file into the 2D array?

Not sure then if it would be better to save the array data to a memBlock and use that memBlock instead of an Array which might give faster speed in program also.

Any ideas or experience of reading/writing to/from files or using memBlocks as arrays? Which would be better?

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C & C++ / now also AGK2! Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga. Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles

Login to post a reply

Server time is: 2024-05-19 03:00:43
Your offset time is: 2024-05-19 03:00:43