|
-
Dec 13th, 2000, 09:22 PM
#1
Thread Starter
Frenzied Member
Sorry for the Subject, but I really didn't know how to describe my problem real short.
I am searching an easy method to Load/save a bitmap, from or in a file with more infos. I want to store a whole Level for a game into one File. So Is there a way that isn't totally slow, to save some types, and than a bitmap to one file?
Sanity is a full time job
Puh das war harter Stoff!
-
Dec 14th, 2000, 03:27 AM
#2
transcendental analytic
Of course there is. I just want to know why you want to have a bitmap in a level before you do something stupid.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 14th, 2000, 10:34 AM
#3
Thread Starter
Frenzied Member
Hehehe before I do something stupid?
I need a background bitmap in my level. This time the game isn't tilebased. No fear I don't try to move a 30000*1024 bitmap over the screen. All I need is a backround Bitmap, that is only used in one Level. The bitmap will be 800*600. Actually it is more than a background, it is the whole level. But I need to store some other information, like some collision infos, and some cordinates for animations.
I hope this was confusing enough to give me the answer. I think I found a way to do it, but I don't like it to much.
Sanity is a full time job
Puh das war harter Stoff!
-
Dec 14th, 2000, 11:13 AM
#4
transcendental analytic
You want it all in one file? Welli was working on something similar to .PAK files in quake a while ago so if you want you could as well continue on my work if you want, (it's not totally complete and there might be some bugs)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 14th, 2000, 12:00 PM
#5
Frenzied Member
Sure there is a way!
Just attach the info you need at the end of the map. If I'm right, the BMP will not be corrupted and you can load it perfectly. Use a keyword like <-- MAP FILE INFO START HERE --> to know where the info begins.
Try it and reply back. If it doesn't work, I know of another way.
-
Dec 14th, 2000, 08:09 PM
#6
Thread Starter
Frenzied Member
Hm I am pretty sure it works, but if I want to save more than one bitmap, it wont work
Sanity is a full time job
Puh das war harter Stoff!
-
Dec 15th, 2000, 03:11 AM
#7
transcendental analytic
Yep, there are dib's but i've never used them, they are like bitmap stacked on each other i think..
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 15th, 2000, 10:40 AM
#8
Thread Starter
Frenzied Member
Hm I am thinking about creating DCs in the Memory, and loading arrays for the bitmap data. Than I use copymemory to copy the Array Data to the Bitmap DC. Will this work?
Sanity is a full time job
Puh das war harter Stoff!
-
Dec 15th, 2000, 02:23 PM
#9
transcendental analytic
well if i'm correct what you're trying to do is loading a bitmap with the array and attach it to a DC, that would work if you had a 24 bit image otherways you would have to use a palette, and stuff...
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 16th, 2000, 12:01 PM
#10
Frenzied Member
Now, wouldn't it be simplier to have one program (the map editor) that converts the image to yor own format and adds all the stuff you want?
I have a module with functions to read and write to an INI file. It couldn't get any simplier:
Code:
'This module has 2 functions to read and write to INI files.
'APIs:
Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpINIPath As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
ByVal lpString As Any, ByVal lpINIPath As String) As Long
'Vars:
Dim INIfPath As String
Public Function ReadINI(ByVal Section As String, ByVal Key As String, ByVal INIPath As String) As String
Dim RetStr As String
If Dir(INIPath) = "" Then Exit Function
RetStr = String(255, Chr(0))
ReadINI = Left(RetStr, GetPrivateProfileString(Section, ByVal Key, "", RetStr, Len(RetStr), INIPath))
End Function
Public Function WriteINI(ByVal Section As String, ByVal Key As String, ByVal KeyValue As String, ByVal INIPath As String) As Integer
'Function returns 1 if successful and 0 if unsuccessful
If Dir(INIPath) = "" Then Exit Function
WritePrivateProfileString Section, Key, KeyValue, INIPath
WriteINI = 1
End Function
Try pasting it into a module! Then it would be simple, just write INI keys to a bmp and voila, there you have! If you want different bitmaps, if they have a fixed size, make different sections of the bitmap, like the first half is the map and the second half is a mask for testing collisions (you surely have seen this before). Otherwise, you can simply have some INI keys give you the coordinates/sizes of each section!
-
Dec 16th, 2000, 12:06 PM
#11
Frenzied Member
Forgot to say, don't confuse INI sections with BMP sections. This is how an INI file looks like:
[section1]
key1=This is key 1's value
key2=...
[section2]
key1=section 2's key 1
key2=...
key3=...
You can name keys and sections as you like, but try using only numbers and letters. The keys' values can be anything that doesn't have a line break.
The BMP sections are different, what I meant is that an area is the map, another area is the player's sprite, another one is the first enemy's sprite...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|