Hello.
I'm doing a Breakout-type game.
Between level 1 and level 2 I've inserted another 1 level game.
But when this one is over and the user goes to level 2 of the Breakout, the pad doesn't appear. If I take the "inter-game" out, the pad will appear normally, but when I include it, it disappears.
Can anyone help me, please?
Thank you.
Sorry Sandra but we can't help you in any way (at least I cant ) until you tell us what you're doing exactly... since you're new I suppose your pad is just a movind picturebox? Or are you using BitBlt or DDraw? When loading 2nd level what happens - do you just load another level map or do you re-init the whole window? *shrugs*
Well I have blabber-vbworld-forum-talk to code powers
Actually I think I know your problem.
It lies in your initializing of the paddle (and maybe someother things), is the level name of the "inter-game" 1? If so then your paddle probably only iniializes on level1, or cannot be reinitialized for some reason. In any event, try destroying it then initializing it after, and if it doesn't work, post some code, as my powers are draining...
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
Fox:I'm using DDraw, and I reinit the whole map again.
Sastraxi:I'll try unloading the picture and then loading it back again.
The fact is that in my level 2, the pad is growing and shrinking back constantly, so I've mad a picture holding all the sizes, and each time I tell him which size, or which part of the image to take. I have seen this used somewhere, and I think it's better than putting each size in a picture by itself and then creating surfaces for all the sizes.
So if I don't want my pad to grow and shrink, the level is working great.
Check the boundaries of Bitblt (if you are using that) that tell where to extract the image from. If you have a mistake in your algorithm that tells from what X,Y to what X,Y to take your paddle picture from the main image, the paddle will disappear altogether.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
The have attached is the whole game, i.e. code and pictures.
It's a runnable version, though with some errors.
If there's something you need to know, let me know.
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Checking out people's biographies, Plenderj? Is that legal?
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
(Sorry for bringing you only bad new but anyway all of them have an easy solution )
It gave me the error "Out of Stack Space" when I hit one of the bricks, and the following line was in the immediate window:
File Not Found: C:\Sandra's Game\Pictures\YBall.bmp
But the file was there! Weird, huh? I tried it again and it worked...
As to the out of stack space error, it probably happened because CheckCollision and MoveBall called each other a few thousand times straight, so maybe they shouldn't be able to do that.
Here's the fix:
Code:
Dim MoveBallAgain As Boolean
Public Sub MoveBall(mb As Integer)
If mb = 0 Then
Ball(mb).XPosition = Ball(mb).XPosition + Ball(mb).XSpeed
Else
Ball(mb).XPosition = Ball(mb).XPosition - Ball(mb).XSpeed
End If
Ball(mb).YPosition = Ball(mb).YPosition - Ball(mb).YSpeed
TryAgain:
MoveBallAgain = False
Call CheckCollision(mb)
If MoveBallAgain Then GoTo TryAgain
End Sub
Public Sub CheckCollision(cb As Integer)
'...
'Where it says "MoveBall (cb)", replace it with: "MoveBallAgain = True"
End Sub
That should work!
Another thing... in some angles, the ball just rolls along the pad. No clue as how to fix it, sorry...
Last one: you didn't give me enough time to see all the balls in the mini-game! I was reading the text when the balls disappeared...
As to your problem... I've studied the code but I simply don't know what's wrong. It *should* work perfecly. But maybe you should try using Blt instead of BltFast, just in case... because Blt doesn't work sometimes while Blt does work. It can be your computer, not your code
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
Hey!
Don't worry about the bad news they aren't that bad.
1-About the "Out of Stack" error, I don't know about it, it has never happened with me, but anyway I'll change the code.
2-About the colors, yes you are right, the user doesn't have the time to read and check the colors, but I had already changed that before I read your post.
3-About tha move of the ball on the pad, I'm aware of this problem, but neither do I know how to fix it. Anyway, I'll try to later.
4-I'll try Blt in stead of Bltfast and let you know what happens.
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Ok. Just don't forget to post here again so I get e-mailed about it
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
(Sorry, but it seems that both of us are busy with other stuff )
Hum... it should work... The out of stack error happens when you call a function too much times (like, function A calls B, B then calls A, that calls B that calls A that calls B...). If you don't immediately call them, but set a boolean variable so you'll call them later (so if you set the variable 100 times it will still call the function only 1), it shouldn't give you any of those errors.
As to your problem: maybe you shouldn't unload the surfaces; instead, the main game loop stops so the inter-game runs, and then it restores the bricks, the balls left, adds 1 to the "level" variable, and continues running.
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
It's easy, all you have to do is have another loop. The main loop will not continue until this one ends (the mine game ends)
But don't forget to still flip to the backbuffer and all that kind of stuff. The main loop will not be running to handle that!
Code:
Do While Running
'Game stuff goes here...
If PlayMiniGame Then
WonMiniGame = False
'The mini game's main loop
Do While PlayMiniGame
'Mini game stuff goes here... when the player wins, WonMiniGame = True
If WonMiniGame Then
GameLevel = GameLevel + 1
ReloadLevelBricks
PlayerBallsLeft = 10
PlayMiniGame = False 'To exit the mini game's loop
Loop
End If
Loop
Last edited by Jotaf98; May 23rd, 2001 at 10:48 AM.
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I have another question:
If I have the following code:
Do
If SomeCondition Then
Newlevel
Exit Do
End if
Loop
Where NewLevel starts a new level, or starts doing something else,
I haven't exited from the loop haven't I? Because the Game has entered the NewLevel procedire, and all its stuff, and hasn't stepped to the next command which is to axit the loop.
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Well, there is no difference at all
Except that with a function the code is more readable, that's all. Just don't unload the surfaces. If you send me the code, I might be able to fix it...
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I was thinking of something about my pad's problem.
What do you think if I put each size in a picture by itself? Do you think it's a bad idea 'coz now I'll have lots of pictures and surfaces, especially that the pad changes size also in other future levels?
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Yes, it's a bad idea, the less images you have the better
If you want to do it, there's no problem, because nowadays *most* computers have enough memory to handle it - but others don't, so...
Anyway, sorry for not replying to your other post
Yes, there isn't any difference. In VB, you can execute only 1 line at a time. Ifs, Loops and Fors just tell VB what line does it have to jump to when certain conditions are met. So, when you execute the function in the middle of the main loop, the function will execute first, and only then it continues with the main loop.
To help you solving your problem: try using the second level's pad in the first level and see if it works. Then try using the first level's pad in the second level and see if it works.
Last edited by Jotaf98; May 25th, 2001 at 11:46 AM.
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Well, that was just to prove that the problem is not with the pads
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I was thinking of doing two different pictures. One normal pad, and another picture with all the different sizes for level2 and above. So in level 1 I load the first picture, and in level 2 I load the second one.
Do you think it could solve the problem?
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Well, when I'm fed up with a program I either forget about it or try something DRASTIC
If I was in your place, I'd make a backup of thw whole game in another folder, and then remove EVERYTHING until I had only the very basic first level... and then rebuild everything from that. Believe me, it's not as hard as it seems since you've got everything planned, and it saved me a lot of projects! Some of the problems were really dumb mistakes , others I never really found out what they were. They just worked when I rebuilt them
Another way to do it would be: (I'm running out of ideas, you know? )
Code:
'Main loop
RestartGame:
Do While Running
'Set Running = False when you wanna activate the mini-game
Loop
Do While MiniGameRunning
'Run the minigame here...
Loop
Running = True
Level = Level + 1
GoTo RestartGame
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."