-
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
-
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:
Code:
Const DOOR = 4
If UpArrowIsPress Then
If NextSpot = DOOR Then
'ChangeScreen
End If
End If
-
how do I tell it where the door is?
-
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 :)
-
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 [email protected] .
Thanks, and sorry for all the trouble,
Spie
-
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
-
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
-
I noticed you had a .map file... what is this for?
-
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?
-
How do I make a Byte Array?
(sorry for all the questions :()
-
Dim A(200) as Byte
or
Dim A() as Byte
Redim A(200)
-
How do I make the map, though?
-
That is the Map.
Regarding your problem with GetAsyncKeyState:
Code:
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
-
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
?
-
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?
-
lol...no (i hate being new :()
-
If the end of the map is 0,0 then use
Code:
If You.X < 0 Then You.X = 0
If You.Y < 0 Then You.Y = 0
-
I'm using a picture box with the picture loaded as my map... am I doing this wrong?
-
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 :)
-
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.
-
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.
Code:
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.
-
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.
-
Is there an easier way to stop the character from running off the screen? Or is there a website that explains it?
-
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.
Code:
If GetAsyncKeyState(vbKeyDown) Then Character.Y = Character.Y + 1
-
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...
-
Hi there
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.
-
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.
-
Either make a character class or UDT, to make a UDT, in declarations type:
Code:
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
-
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.
-
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.
-
That's what I mean, use UDTs but not class modules.
-
UDTs are classes without Subs and Functions... in C Structs are the UDTs and structs are the same as classes (internal).
-
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... :)
-
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 :)
-
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 ;)
-