Click to See Complete Forum and Search --> : RPGs - Map file?
Spie
Sep 29th, 2000, 04:14 PM
I'm in the process pf making an RPG. I need to know:
-How to stop the character from wondering off the screen
-How to make the screen change when a character touches a certain spot (like a door)
-How to deal with money...
I may be asking for a lot, but... hey every VB prrogramer was new at one time!
Thanks,
-Spie
Fox
Sep 30th, 2000, 11:13 AM
Clip the characters to the screen... Implement a script system so the tiles where the player walks on perform an action as changing the map...
Money maybe a property of the player, if you have vendor characters you should make a little talk-system so the player can buy things and then just add/subtract money from the chars..
To make the screen change when you hit a door, simply check the spot before you move, for example:
Const DOOR = 4
If UpArrowIsPress Then
If NextSpot = DOOR Then
'ChangeScreen
End If
End If
Spie
Sep 30th, 2000, 12:10 PM
how do I tell it where the door is?
drewski
Sep 30th, 2000, 06:49 PM
When you do something like this you need to keep track of where things are. In doing this you need to keep track of the following:
1. When you make the map you need to find the X & Y coordinates of where the door is.
2. You need to keep track of the X & Y coordinates of where the character is as he moves around.
3. When the X & Y coordinates of the characters position equal that of the doors you need to change the picture.
When making a game Spie you always need to keep track of everything. You sound as if you are pretty new to this type of thing :)
Spie
Sep 30th, 2000, 07:09 PM
Uh. Yeah, I am rather new. I am trying to learn C++, but I can't get a strait answer from anyone. I came back to VB because everyone seems nicer... Heh, maybie I am just wierd!
I may be doing this wrong... I made the background of the form the picture of the screen. I do not think this is right is it? If not... If it is not too much trouble, please tell me how. If you want to, you can e-mail me so you don't flood this form. My e-mail adress is acaron@destinfla.com .
Thanks, and sorry for all the trouble,
Spie
Spie
Sep 30th, 2000, 07:11 PM
Btw. I like your signature :)
I see said the blind man to his deaf wife...
Try storing your Map in a Byte Array. That way you have your whole map in "1 variable". Then when you are about to move the character, do the following:
Check which direction (and get the X and Y positon)
Get the type of tile in that current position
Check if it's a door (or whatever)
If so, then do a special action
drewski
Sep 30th, 2000, 07:33 PM
Well I could give you a little help on problems here and there but I'm not the best programmer out there. VB is just a hobby of mine and I'm not one of those people who program 24 hours a day :) If I were you I would go and find some tutorails online somewhere.
I learned all of my basic stuff from gollum's site : http://www.oneringsoftware.com
I started a game once but I didnt finish it all the way. It just got to be too much work. The grafix arent that good, the code was a nightmare, and it is only half way commented. If you want to take a look at it is at my new website here: http://www.geocities.com/adt_vb/index.html
I would also asking someone else with more experience than me such as Fox. He'll probably be able to answer most of you questons. But hey I'll give them a try :)
drewski
Spie
Sep 30th, 2000, 09:23 PM
I noticed you had a .map file... what is this for?
Spie
Sep 30th, 2000, 10:17 PM
Ok, I'm chanign the topic again! lol I am using GetAsyncKeyState... How to I make it return to what it was before the button was pressed?
For example, Label1 was set to say "Hi". When you pressed the up key it was set to say "Hello". How do I make is go back to "hi" when you release the key?
Spie
Oct 1st, 2000, 01:58 PM
How do I make a Byte Array?
(sorry for all the questions :()
Fox
Oct 1st, 2000, 02:41 PM
Dim A(200) as Byte
or
Dim A() as Byte
Redim A(200)
Spie
Oct 1st, 2000, 07:29 PM
How do I make the map, though?
That is the Map.
Regarding your problem with GetAsyncKeyState:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyUp) Then
Label1 = "Hello"
Else
Label1 = "hi"
End If
End Sub
Spie
Oct 2nd, 2000, 06:13 PM
Thanks, That helped.. but how do I stop the character from leaving the screen. Do I change the number in:
Dim A(500) As Byte
?
Fox
Oct 3rd, 2000, 12:07 AM
The number in A(23) is for example 4. Then you have a tile array where such things are stored: Tile(4).Collides = True
know what I mean?
Spie
Oct 3rd, 2000, 02:17 PM
lol...no (i hate being new :()
If the end of the map is 0,0 then use
If You.X < 0 Then You.X = 0
If You.Y < 0 Then You.Y = 0
Spie
Oct 3rd, 2000, 05:03 PM
I'm using a picture box with the picture loaded as my map... am I doing this wrong?
kedaman
Oct 4th, 2000, 02:58 AM
Yeah, you need to start over, to have a map based rpg you need to draw tiles, set up a game structure by using UDT's and some basic graphical methods for drawing a scrollable tiled map with sprites. I think you'll find a lot of that at Fox programming site :)
Spie
Oct 4th, 2000, 09:35 PM
Ok, im gonna go alittle off topic again... how do I animate a four frame picture? I only have the code for a two frame animation.
kedaman
Oct 5th, 2000, 05:51 AM
This shows how yo use UDT's for for instance animated frames, you make a counter that goes from 0 to the amount of frames-1 and then store the frames in a dynamic stdpicture array.
Type animation
counter as byte
frames as byte
pic() as stdpicture
end type
Dim spie as animation
Sub Animate(Ani as animation)
Ani.counter=(Ani.counter+1) mod ani.frames
end sub
Sub showAnimation(Ani as animation, target as stdpicture)
Set Target.picture=ani.pic(ani.counter)
end sub
A good idea to keep organized is to make a class for a player. In there, you can create properties for Frames, X and Y positions, hitpoints, strength etc.
Spie
Oct 6th, 2000, 01:16 PM
Another question (sorry) :)
How do I return the character to the normal standing position? I can make him look like he is running, but when he stops he is still on one leg.
code:
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
If GetAsyncKeyState(vbKeyDown) Then
char1.Picture = chardown.Picture
char1.Top = char1.Top + 70
End If
I tried using the else thing, like I did on the labels, but it didnt help.
Spie
Oct 7th, 2000, 02:47 PM
Is there an easier way to stop the character from running off the screen? Or is there a website that explains it?
kedaman
Oct 9th, 2000, 05:58 AM
1. YOu can implement scrolling in your game, and make it scroll automatically when you get to one edge of the screen
2. You can check if the character position is at any edge of the screen and disable him from moving
3. You can make him teleport to the other side of the screen, well this depends how you want your game to react when he comes to an edge.
To make him stop running, just blit the not-running image over him when you haven't pressed any key to move him.
Spie: Why not use a Map for your character? It'll be much easier.
If GetAsyncKeyState(vbKeyDown) Then Character.Y = Character.Y + 1
Spie
Oct 11th, 2000, 06:54 PM
How do I "define" .y and .x? I have tried putting it in the module, but the program seems to want to discard that information...
Das Mad
Oct 11th, 2000, 11:10 PM
You have a lot of questions, maybe you should get a VB-Book.
Not for amateurs but for Users so that you can lookup these
common questions.
I hope you don't move around imageboxes.
Collect all the data for the next screen and then use 'drawpicture' to get it on the screen.
Tip: U should not use any thing but Static pictures, Perhaps the background Image Could be a Image box and the
Interface.
This was a thing I used to do wrong.
tonyenkiducx
Oct 12th, 2000, 04:47 AM
Heres what I found to be the easiest way to program a movement system.
Create 2 arrays, one is your map, the other is your Character.
Dim CharacterArray(5)
Dim MapArray(10,10,1) ' this will allow for a set of squares, 10 by 10.
Then you need to setup the map array, you need to draw the 10 by 10 grid on paper, and draw your map on it using 1 square as a location. Then make a note on each square what exits are available, using N for north, S for south and so on. Then match up the grid locations, (i.e. 2(across),5(down)) and do...
MapArray(2,5,0) = "NS" ' this tells the program that the user can move North, and South
MapArray(2,5,1) = "An empty Street" ' This is the description of the location.
Then the character array contains this data.
CharacterArray(0) = "Allanon" ' There name
CharacterArray(1) = 0 ' There Across position in relation to the maparray
CharacterArray(2) = 0 ' There Down position in relation to the maparray
Then When a character requests to move, all you need do is this code...
If moverequest = "N" and instr(maparray(characterarray(1),characterarray(2),0),"N") Then
CharacterArray(2) = CharacterArray(2) + 1
End If
TO move south, just subtract 1 from that, and user characterarray(1) for moving east and west.
Then all you need to do it print out the description..
User.Screen.Caption = maparray(characterarray(1),characterarray(2),1)
You can expand on this lots, adding up and down, is very easy, and both the character array, and the map array can have any amount of extra data added to them.
Tony@Work.
kedaman
Oct 12th, 2000, 05:28 AM
Either make a character class or UDT, to make a UDT, in declarations type:
Type Character
X as integer
Y as integer
'more here later when you need more characteristics..
end type
Or for a classmodule, add a new classmodule to your project and declare X and Y as public variables in it, or as two private variables with property get and let statements to access them
HarryW
Oct 12th, 2000, 09:53 AM
Do you think it might be better to stick to procedural programming for a while until he properly understands it? It's perfectly possible to do it procedurally, without object orientation, and it might make things simpler.
kedaman
Oct 12th, 2000, 10:09 AM
Well UDT's aren't OO, but they are useful anyway so i think we could keep them, since it gives your game a nice structure without getting Object oriented.
HarryW
Oct 12th, 2000, 10:16 AM
That's what I mean, use UDTs but not class modules.
Fox
Oct 12th, 2000, 11:12 AM
UDTs are classes without Subs and Functions... in C Structs are the UDTs and structs are the same as classes (internal).
Fox
Oct 12th, 2000, 11:12 AM
UDTs are classes without Subs and Functions... in C Structs are the UDTs and structs are the same as classes (internal).
Both, classes and structs/UDTs are only to make code easier and probably faster... :)
kedaman
Oct 12th, 2000, 11:20 AM
Yeah Fox that's generally what differs UDT's and classes.
But there are some other differences:
Objects have an address and has to be instanced with NEw keyword. Types are always types, not any references. YOu can't pass a type byval :( and types must be passed to methods with the correct argument, with object you can use As object and pass anything.
Objects also takes up more space and are slower to use :(
well hope i didn't sound like objects are bad, they rock if you use them in the correct situation :)
Fox
Oct 12th, 2000, 11:35 AM
Of course, I just wanted to say that in C both are the same. They're both the same speed, take the same memory... managed exactly the same ;)
kedaman
Oct 12th, 2000, 11:50 AM
Ah, that sounds easy :)
Originally posted by HarryW
That's what I mean, use UDTs but not class modules.
I disagree with this. When using classes, you have the advantage of methods, events as well as properties. This way, you can have all your "Player Oriented" code organized in 1 module.
kedaman
Oct 12th, 2000, 03:01 PM
Well for a newbie it would be easier to just start with UDT's, what Harry said, and i agree myself even if classes would be a better solution this time
HarryW
Oct 12th, 2000, 03:19 PM
Yes, I think it's probably a good idea to get procedural programming fairly clear before you start using class modules. From a functional point of view class modules are useful, but, well... it's like Kedaman said.
Spie
Oct 15th, 2000, 07:54 AM
Hey, Drewski, I was looking at that Keldon game and noticed you were using a .map file. How did you create it?
kedaman
Oct 15th, 2000, 09:37 AM
I'm not drewski but i can tell you have a map file is stored...
1. You have a header with the general info, usually just some fixed length of parameters most important Width and Height of the map.Maybe you could add up map name and description, spritecount and info about other layers but that can be done in a later map version. Also if you have many parameters you can store them in a UDT
2. The map data, easy for one or two dimensioned arrays with one layer as you can just store them as you specified the size in the header. Several layers can be written in the same multidimensioned array or separate, just remember the order.
3. Sprites, scripts, game and other data that might be stored in dynamical arrays. Not nessesary to start with either.
A simple example:
Open File for Binary as #1
Put #1,,Width
Put #1,,Height
Put #1,,Map
Close #1
Whereas declarations should be
Private Map() as byte 'a dynamical 1 or 2 dimensioned array
Private Height as byte 'huge maps are inefficient when it comes to coordination
Private Width as byte 'therefore we store these in byte datatypes
Spie
Oct 18th, 2000, 07:07 PM
I cannot explain how much farther I have gotten because of this form!! I would like to say, Thank you. But... I have another question, lol! Fox, I have been looking at your animation demo and have figured out how to make a "replica" of it. Well, I changed the character... The only thing is...It won't tile. The screen looks like it isn't refreshing. How do I make the grass tile and the ugly smudge go away?
Thanks!
Fox
Oct 19th, 2000, 01:53 AM
I think your problem is that you dont clear the buffer. In my demo I draw the grass tiles each frame, meaning I just overdraw the whole last player. Hope this helps ;)
Spie
Oct 19th, 2000, 11:36 AM
How do I clear it?
Fox
Oct 20th, 2000, 12:26 AM
You can use a simple Cls or if you need it faster try the FillRect API... dunno how fast they are, I don't need to clear my buffer ;)
Spie
Oct 20th, 2000, 02:12 PM
Why don't you have to clear yours?
HarryW
Oct 20th, 2000, 07:10 PM
I think what he means is he redraws all the tiles again on the buffer, then draws the character ontop. If you're redrawing the whole background every time you don't need to clear the buffer, you can just overwrite it.
Fox
Oct 21st, 2000, 06:55 AM
Exactly. ;)
Spie
Oct 22nd, 2000, 03:13 PM
Ok... I've spent a day trying to figure out how to overwrite it. lol it some code and is it in the animation demo?
Spie
Oct 22nd, 2000, 03:21 PM
To see a picture of the problem goto:
http://www.geocities.com/spie_12345/problem.html
kedaman
Oct 22nd, 2000, 04:22 PM
Looks like the tileset is missing, or at least only two tiles are showing their precense
Spie
Oct 22nd, 2000, 04:39 PM
Um, please excuse me if I am rude in some way.. I was just suspended from a game because a Gamemaster was abusing their power, but, I tryed turning autoredraw off(just for the fun of it) and it showed the part of the form around the tile. lol I was really cool lookin'. I dunno if this has anything to do with it but...hey! :)
Spie
Fox
Oct 23rd, 2000, 11:27 AM
As I remember in my demo is only one background tile, so did you try to add more tiles? If not you probably deleted some parts of the draw sub so it doesn't draw all tiles or something..
Well, what background do you exactly need by the way? If it should be white you can use a simple clear screen before calling the draw sub...
Spie
Oct 23rd, 2000, 02:15 PM
Uh... right now I'm just trying to get the structure of the game down. Is there an easy way to add like a building or a tree?
kedaman
Oct 23rd, 2000, 05:05 PM
Ah, well you could either use spites layer or a another map layer ;) Go check Fox der-zirkel engine on how to blit transparent layers.
Spie
Nov 3rd, 2000, 08:32 PM
Hey Fox I have another question...lol
I downloaded your scrolling demo (which is also a really big help) and saw a section fromthe code that may solve my problem. It is the section that randomizes the map.
( For A = 0 To MapW
For B = 0 To MapH
Map(A, B) = (picTile.Count - 1) * Rnd 'Randomize tile in map
Next
Next)
I changed the - to a + and almost the same thing happend in the demo as my game. So I tryed to put the code in my game. I defined everything but one thing. the picTile.count. Where do I define that?
Fox
Nov 4th, 2000, 05:28 AM
picTile is the picture box (control array) where I hold my tiles in. You can replace this by the number of tiles loaded in your game to this time ;).
Spie
Nov 4th, 2000, 08:40 AM
Replace the "picTile.count"? That is where I am getting my error.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.