PDA

Click to See Complete Forum and Search --> : Terrain/gamearea editor question


Salosara
Dec 4th, 2000, 09:19 AM
This is what i would like to do...

-i have the graphics blocks 16x16 pixel Gif files
160 different pieces

-the gamearea or the terrain is in a file.
Starting from 38618 and ending 42618,
So it is 4000 values of size.

- So first i open the file as binary
- second i want to Get an array of 4000 values. as stated
above

Q u e s t i o n :

How to: get the array in any tyoe of values, that are easy to convert to hex values ?

How to: Show it on a form in an editable way ?
50 Rows and 80 Columns

I'm really a novice in vb programming but i (think) i know
quite clearly that this is the way to start to do my Game-area-editor ; )
Please help me

Simo Salosara

/\/\isanThr0p
Dec 4th, 2000, 09:44 AM
What do you mean by easy to convert to hex? you can get the hex of every integer as string.

Show them in an editable way:
I normaly use a picturebox and I blt smaller versions of those bitmaps on there. Then just put some code on the mouse down event of the picturebox something like

map(x/tilewidth,y/tileheight) = edittile
that sets the value of "edittile" to the array.

this works if you store your map in an 2d array, but you coul also use a normal array for this.
write me an email if you are interested in one of my mapeditors.

Salosara
Dec 4th, 2000, 09:58 AM
Ok Maybe i have to ask just the specific Question, so you wont think i can infact do it already.
Forget the stuff on the earlier post : )


1.How to use the Get statement to get an array of (i.e) 40
values

Get #1 38618, values 'returns the first value
'in this case 33

2.How to show the values in hex

(yes i have been studying the help files...)

Thanks again for your reply!

/\/\isanThr0p
Dec 4th, 2000, 10:17 AM
That makes it easier for me.
When I understand you right, all you need is hex(number) to get a string with the hex of a number in there. Is this what you want? (probably not)

As far as I know, you can't just read an array. I alsways out it into a loop to get every singe value. I know that is slow, but in my applications that was always good enough.
If this isn't good enough for you, you could try something like loading it to a string. Than what you do is get the pointer of your array and the string and use copymemory to copy the data of the string to the array. I think that should work, but I can't give you code.

Salosara
Dec 4th, 2000, 10:38 AM
OK! Thanks

so if i use a loop to
get the values individually to a string,
How will i do it ? with Do while...
or with For... Next...

And how to stop the loop when (for example) 40 values have been read ?
And is it the Get statement that i use ?

-please don't get bored of me :)

Thanks again

kedaman
Dec 4th, 2000, 03:43 PM
Misan! Great news for you, you can read an array, and it's tons faster than to loop. ;)
Salora, what type of array do you need to read? A fixed length datatype should be easy

Get #1,38618,yourArray

Non fixed, like variable length strings and some UDT's need to be prebuffered.

/\/\isanThr0p
Dec 4th, 2000, 07:42 PM
So I just can read everything from my array? My array is 2d?
And How do I save this? I couldn't just save the array!
What is going on here?? :)

kedaman
Dec 4th, 2000, 07:58 PM
Yes you can save any array in any dimensions ;)

PUT#filenumber,location,arrayname

Salosara
Dec 4th, 2000, 08:18 PM
Ok Kedaman gave this line a few posts back:

Get #1,38618,yourArray

and it's about the same as what i have been trying.


Dim rivi1(1 To 4000) As Byte
Get #1, 38619, rivi1

but this seems to return only the value that's in
38619 !! (it's the first of the 4000 values.)

What am i doing wrong??

kedaman
Dec 4th, 2000, 08:43 PM
That should work, btw you have to open in binary, not random, if thats what youre doing? "rivi" sounds finnish, oletko suomalainen?

Salosara
Dec 4th, 2000, 09:12 PM
Thanks & Kiitti !

So, I have opened the file as binary.
and then this:
Dim rivi1(1 To 4000) As Byte
Get #1, 38619, rivi1
text1=rivi1

And i get a bunch of ASCII codes wich are not what they should really be and there are just 2000 of them.
with Dim rivi1(1 to 40) as byte , i get just 20 ASCII codes.
So i think i'm getting close but i would need numerical values preferrably Hexcodes of the 4000 values.
How can i do this??

(Ja suomalainen versio...)
No joo, oon Suomalainen, Morjesta vaan !
Mutta ei tuo koodi kyllä vielä ihan toimi...
vaikuttaisi siltä että arvo joka tuosta rivi1 tulee nyt on
sarja ascii koodeja jotka ei täsmää sen kanssa mitä tiedostossa pitäisi olla,
Ja esim Dim rivi1(1 to 40) antaa vaan 20 ascii koodia eli puolet vähemmän.

textbox on varmaan väärä juttu mutta miten saisin numeeriset, mielellään hexakoodi arvot tästä?
Kiitti jos pystyt vielä neuvomaan :)
on ehkä silti parempi kirjottaa englantia, jos jollain olis tähän asiaan jotain sanottavaa vielä :)

kedaman
Dec 4th, 2000, 10:14 PM
on ehkä silti parempi kirjottaa englantia, jos jollain olis tähän asiaan jotain sanottavaa vielä

hehe, niin pitäisi, muuten misan ja muut eivät tajuaisi mitään ;)

Well misan, you could try figuring out what that was all about, hehe. Strings in vb are unicode by default so by converting a byte array to a string just using string=bytarray won't make it unicode.

The solution is strconv:

text1=strconv(rivi1,vbunicode)
'instead of
text1=rivi1

that should work :)

Salosara
Dec 5th, 2000, 09:23 AM
OK ! Kiitos jälleen !

That seems to work!
Now i'm still thinking how to let the user edit the values.
now i get a screen full of weird ASCII-codes and if i wanted to replace let's say this character:

" :ASCII = 34 :decimal = 22 :hex

with this

! :ASCII = 33 :decimal = 21 :hex

what do i call them in the code ?
Can the unicode number ( !=33) be used ?
let's say if i want to assign a terve.gif picture to unicodevalue 33

for example if we have a line of four codes

33 12 55 23

I could present 4 different Gif files in a row according to the values.
(as i wrote in the first post, this is going to be a Game/Terrain editor)

Kedamanille sellaiset terveiset, että jos tuosta englannista ei saa selvyyttä, niin kysy pois ... ;)
Tämä alkaa kyllä tästä hahmottumaan!


Simo Salosara

/\/\isanThr0p
Dec 5th, 2000, 09:42 AM
Hey you guys. Probably you have seen the "I want a muscian" thread. I was talking German in there with some others. Even though we talked English again, they deleted our thread!

Salosara
Dec 5th, 2000, 01:41 PM
Thanks Kedaman, that was useful info also!

Now i have done a total of 50 strings of unicode of the
game area and i'm trying to enter the next phase of this project.

So i have now on the gamearea 160 different unicodes and
the next thing is that i must do a form where i make
graphical display of this information.

For example if the top row would be all "water", all 80 values. then the program should read the walues and check what they are.

For example the first value on the first row could be 31
and it would mean that on the upper left corner, the first
16x16 pixel graphicalblock would be 31.gif

Is a loop of some sort be a best way to go ??

What is the best way to do this kind of thing,
when i have the 160 GIF files on the disk separately ?

kedaman
Dec 5th, 2000, 01:49 PM
Well, i've been developing this kind of game some years ago, i suggest you could have a look at Fox programming site, he has the link on his signature ;) There's a great demo on how you can blit terrains with bitblt Api.

Salosara
Dec 7th, 2000, 10:49 AM
Hello again !

i managed to get the info to the MSFlexGrid
and i was wondering
how to use the: Cellpicture
is it possible to make the what picture to load, depended
on the value in the cell ?

for example: if the value in the first cell is 33
then the program would add C:\33.BMP to the first cell ?
(as i read from the help, both can exist in the same cell at the same time.)

i also found that i couldn't change the values in the flexgrid while the program is running, what i'm doing wrong?



By the way, if you think i'm really going the wrong way with this, just tell me if this Flexgrid/cellpicture is no good!

Simo Salosara

Salosara
Dec 7th, 2000, 08:02 PM
Thanks Kedaman...

Ok the MSFlexgrid is forgotten i already have visited
The Coding site from Fox McCloud and i planned to study
His sources,tips and tutorial as the next thing :)

Within a week or so i'm back with a new set of fresh problems ;)