|
-
Jun 30th, 2000, 01:25 PM
#1
Thread Starter
Hyperactive Member
Im making a somewhat simple as I thought game that has ballons rise from the bottom of the screen at random locations. I can't figure out how to get images to move. Any help is appreciated
Matt 
-
Jun 30th, 2000, 02:03 PM
#2
transcendental analytic
put a balloon picture in a image control and then put this code in a commandbutton event or whatever...
Code:
Dim speed&
image1.move rnd*scalewidth,scaleheight
speed=30
Do
image1.move image1.left,image1.top-speed
doevents
Loop until image1.top<0
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.
-
Jun 30th, 2000, 06:06 PM
#3
Thread Starter
Hyperactive Member
Matt 
-
Jul 2nd, 2000, 12:26 AM
#4
Lively Member
Controling the movement... I cant figure it out
I can't figure out how to control a picture... like an RPG type game. How do I make it to where I can press an arrow button and make a character move around on a .bmp Background, or can i?
-
Jul 2nd, 2000, 04:04 AM
#5
transcendental analytic
Not too hard, here's just an example, if you want to have acceleration involved just put an extra couple of variables handling velocity.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp
image1.Top = image1.Top - speed
Case vbKeyDown
image1.Top = image1.Top + speed
Case vbKeyLeft
image1.Left = image1.Left - speed
Case vbKeyRight
image1.Left = image1.Left + speed
End Sub
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.
-
Jul 2nd, 2000, 11:01 AM
#6
If you use the GetAsyncKeyState API, you will be able to have more flexiblity. The standard KeyDown or KeyAscii will not allow you to press more than 1 key at a time, this will.
Code for a module.
Code:
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Code for a Timer. Set the Interval to 1.
Code:
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyLeft) Then Image1.Move Image1.Left - 100
If GetAsyncKeyState(vbKeyRight) Then Image1.Move Image1.Left + 100
If GetAsyncKeyState(vbKeyUp) Then Image1.Move Image1.Left, Image1.Top - 100
If GetAsyncKeyState(vbKeyDown) Then Image1.Move Image1.Left, Image1.Top + 100
End Sub
-
Jul 2nd, 2000, 01:14 PM
#7
-
Jul 2nd, 2000, 01:32 PM
#8
Lively Member
-
Jul 2nd, 2000, 01:33 PM
#9
In my example, you need a Timer and an ImageBox. You can use a PictureBox in place of the ImageBox, just make sure that you name it Image1.
-
Jul 2nd, 2000, 01:39 PM
#10
Originally posted by Spie
Never mind... I got it working
But now I have another question... How do I make barriers... So my character wont keep walking when he gets to the end of the form, or picture? Lol, I full of questions 
-spie
It depends. Are you making your character move at a fixed/relative size? (like Chip's Challenge) or is he moving Bit by Bit? (at no relative size)
If it's at a relative size, before you move your character, check which position he is on your Map and if he's moving into a block, don't move him.
If it's the Bit by Bit, you might have to research into collision detection.
-
Jul 2nd, 2000, 01:56 PM
#11
Lively Member
uhh
Uh, I'm testing this with link from Zelda: a Link to the Past. I am going to making my game similer to this one. I just need to know how to make "Invisible walls"... So the character can't leave the screen... I also need to know how to make him change direction with each key... For example, when I press the up key, the character points in that direction. When I press the right key, he points in that direction.
One more question... If I'm not boring you to death. How do I make it look like he is running? Do I need an animation?
As I said, I know almost nothing about this 
-Spie
-
Jul 2nd, 2000, 03:27 PM
#12
Yes, animation is required if you want to make it look like he is running. Even a simple 2 frame animation would work.
You can make him change direction by having 4 seperate images, each from the different directions and have it change when the Direction key is pressed.
For example.
Code:
If GetAsyncKeyState(vbKeyLeft) Then
'Change the picture so he is facing left, we assume
'that imgCharLeft is a picture of the character facing left
imgCharacter.Picture = imgCharLeft.Picture
imgCharacter.Left = imgCharacter.Left - 100
End If
-
Jul 2nd, 2000, 07:13 PM
#13
Lively Member
Um... It makes the character turn left, but not move left.
How do I make him go left? How do I make him go in the other directions?
And how do make barriers?
-
Jul 2nd, 2000, 09:20 PM
#14
transcendental analytic
Sorry to disappoint you, but you can't continue like this, making this game will take ages, you will find Fox site a lot usefull, ask him and he will give you some advice.
Fox McCloud's homepage
http://foxmccloud.tsx.org/
btw, Getasyncstate will allow you to press several keys at once and monitor them
Also you could ask me an i'll give you some samples how to create a game structure by using classes 
Thrust me, I know games.
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.
-
Jul 2nd, 2000, 09:31 PM
#15
Lively Member
Lol, I only need to know how to move the character in different directions... Do you know how? 
-
Jul 2nd, 2000, 10:26 PM
#16
-
Jul 3rd, 2000, 12:07 AM
#17
PowerPoster
-
Jul 3rd, 2000, 08:00 AM
#18
Spie:
The example I have you before should have worked. But maybe you did not have the correct controls on. Make 2 PictureBox's and called them imgCharacter and imgCharLeft. Then make a Timer and Set it's Interval to 1.
Code for a module
Code:
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Now put this Code into the Timer.
Code:
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyLeft) Then
'Change the picture so he is facing left, we assume
'that imgCharLeft is a picture of the character facing left
imgCharacter.Picture = imgCharLeft.Picture
imgCharacter.Left = imgCharacter.Left - 100
End If
End Sub
This is just a simple example using Controls for simplicity
sake. when you are making a game, use you should consider using DirectDraw or BitBlt.
-
Jul 3rd, 2000, 11:40 AM
#19
Lively Member
That works, but he keeps pointing left. Where should I put the other two pictures?
-
Jul 3rd, 2000, 12:06 PM
#20
There should be 1 main picture for the character and 4 other pictures for the different directions. For the 4 that you are not using, set their Visible property to False.
-
Jul 3rd, 2000, 12:26 PM
#21
-
Jul 3rd, 2000, 12:52 PM
#22
Not at all. That's what these forums are for.
-
Jul 3rd, 2000, 01:18 PM
#23
Lively Member
Ok, I didn't understand what you said about "invisible walls" Is there some kind of code that will stop the character from going past a certain point?
-
Jul 3rd, 2000, 01:42 PM
#24
Well that depends on how you are making the game. Firstly, how do you have your Map stored? Is it in an Array? Secondly, are you making your character move at a fixed/relative size? (like Chip's Challenge) or is he moving Bit by Bit? (at no relative size)
-
Jul 3rd, 2000, 02:14 PM
#25
Lively Member
What do you mean by map? Do you mean the screen he is walking on? If not... I need help with that (figures), lol.
I have never played Chip's challenge... Have you played Zelda for the super nintendo (A Link to the Past)? That is the kind of game I am talking about. If you don't have it you can download an emulator for it... ZSNES is a good one.
Thanks,
Spie
-
Jul 3rd, 2000, 02:47 PM
#26
Yes, the map is what you play on. For example, a simple Map could look something like this.
9 = You
2 = Item
1 = Wall
0 = Walkable
0000000000
0111110000
0000000000
0100200020
0100000000
0100009000
0100000000
0000000000
0111100000
0000100020
-
Jul 3rd, 2000, 03:30 PM
#27
-
Jul 4th, 2000, 02:12 PM
#28
Lively Member
Animations
How do I get animations to play?
-
Jul 4th, 2000, 02:48 PM
#29
You can store that Map in a 2 Dimensional Array.
To play simple animations, you can use a Timer. Make 3 PictureBox's. picMain, pic1 and pic2. Make the Picture in picMain and pic1 the same and load a different one into pic2.
Put this code into a Timer and set its Interval to 200.
Code:
Private Sub Timer1_Timer()
'If our Picture is the 1st frame then
If picMain = pic1 Then
picMain = pic2
Exit Sub
Else
'If it's the 2nd Frame
picMain = pic1
End If
End Sub
-
Jul 4th, 2000, 04:49 PM
#30
Lively Member
Is there any way to speed up the animation?
-
Jul 4th, 2000, 04:55 PM
#31
Lively Member
sorry for two posts, but I forgot to ask how to make a 2d array...
-
Jul 4th, 2000, 04:59 PM
#32
transcendental analytic
In your declarations (in a form not class or else use private instead of public)
Public map() as byte
Public Width as long, Height as long
And in your initial code (ie sub form_load)
Height=50:width=50
Redim map(Width,Height)
No you can't speed up that without having to use layers with device context, or better up DirectDraw
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.
-
Jul 4th, 2000, 05:03 PM
#33
You can speed up animation by setting the Timer's Interval to a lower number. If you do not want to use the Timer for animation, use BitBlt or DirectDraw (The best one).
-
Jul 4th, 2000, 06:37 PM
#34
Lively Member
Ok, I have seen a .map file... Is that what I need?
-
Jul 4th, 2000, 07:49 PM
#35
Lively Member
Again, sorry for two posts, but is there some way to make the picture of the character less choppy? When I move sometimes the background turns to white for a second, then changes back to being transperent. Is it the animation?
-
Jul 4th, 2000, 08:31 PM
#36
Frenzied Member
Wow! this post is getting long! I haven't been able to get these things working that your talking about. Can you send me an example of what you guys are talking about? Im very interrested in maps and 2D arrays.
[email protected]
-
Jul 4th, 2000, 09:16 PM
#37
transcendental analytic
Steve, Go download the demo from Fox page
Spie, You have to post some code, or probably the whole form, eventually send your project if you want to solve that kind of problems because anything can cause that.
If you want to store your map you could have use of a .map file
Open it in binary and to read with get and write with put
How to save map:
Code:
ff=freefile
Open yourfile for binary as ff
put ff,,Width
put ff,,Height
put map
close ff
How to Load map:
Code:
ff=freefile
Open yourfile for binary as ff
get ff,,Width
get ff,,Height
redim map(width,height)
get map
close ff
[/code]
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.
-
Jul 4th, 2000, 10:02 PM
#38
Lively Member
How do I make a map? Where do I put the code?
-
Jul 5th, 2000, 01:17 AM
#39
transcendental analytic
This code will store your map array binary so you will have to use an hex editor if you want to edit it externally..
Instead you could edit it in you game, that would be much easier.
Your map will be created in memory as soon as the array is initialized, and it will be stored on your harddrive by using the save map code i gave you.
Put it in a commandbutton, a menu or whereever you want. I would recommend you make procedures for them so that you can call them anywhere you want
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.
-
Jul 5th, 2000, 02:16 AM
#40
Lively Member
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
|