Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

loop problemalternate 2

Hi World,
I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.


THX
Dhruv(BattleGuard)

Comments

  • korkor Posts: 198Member
    : Hi World,
    : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    :
    :
    : THX
    : Dhruv(BattleGuard)
    :
    :
    check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
  • BattleGuardBattleGuard Posts: 166Member
    Hi,
    Thanx for the response but i am currently only focusing on VB.Net. I am actually very new to programming and game graphics adn pc graphics. I am also learning a little 3ds max 4.I am only 12 years old, after all. I don't want you to think that i am dumb or i won't understand or anything. I am good with logic and stuff.

    Thx for the response
    Dhruv(BattleGuard)



    : : Hi World,
    : : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    : :
    : :
    : : THX
    : : Dhruv(BattleGuard)
    : :
    : :
    : check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
    :

  • MatrixxMatrixx Posts: 3Member
    What you need to do is set up multiple threads, at least one to for the loop and another to handle user input. I am suspecting the reason you are having a problem is that the loop runs continuously and never stops and looks to see if the user has attempted to move the paddle. You can set up a thread and cause it to sleep for a small amount of time, in that time the other thread can update the paddle position, then sleep and go back to the loop. If this does not help just post again.

    : Hi,
    : Thanx for the response but i am currently only focusing on VB.Net. I am actually very new to programming and game graphics adn pc graphics. I am also learning a little 3ds max 4.I am only 12 years old, after all. I don't want you to think that i am dumb or i won't understand or anything. I am good with logic and stuff.
    :
    : Thx for the response
    : Dhruv(BattleGuard)
    :
    :
    :
    : : : Hi World,
    : : : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    : : :
    : : :
    : : : THX
    : : : Dhruv(BattleGuard)
    : : :
    : : :
    : : check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
    : :
    :
    :

  • BattleGuardBattleGuard Posts: 166Member
    Hi,
    How exactly would i cause it to sleep and what kind of thread do you mean?

    THX
    Dhruv(BattleGuard)



    : What you need to do is set up multiple threads, at least one to for the loop and another to handle user input. I am suspecting the reason you are having a problem is that the loop runs continuously and never stops and looks to see if the user has attempted to move the paddle. You can set up a thread and cause it to sleep for a small amount of time, in that time the other thread can update the paddle position, then sleep and go back to the loop. If this does not help just post again.
    :
    : : Hi,
    : : Thanx for the response but i am currently only focusing on VB.Net. I am actually very new to programming and game graphics adn pc graphics. I am also learning a little 3ds max 4.I am only 12 years old, after all. I don't want you to think that i am dumb or i won't understand or anything. I am good with logic and stuff.
    : :
    : : Thx for the response
    : : Dhruv(BattleGuard)
    : :
    : :
    : :
    : : : : Hi World,
    : : : : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    : : : :
    : : : :
    : : : : THX
    : : : : Dhruv(BattleGuard)
    : : : :
    : : : :
    : : : check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
    : : :
    : :
    : :
    :
    :

  • korkor Posts: 198Member
    Threads are overcomplicating a simple problem, and add a good amount of overhead. Even seperate functions, subroutines, or procdures, which are all the same thing in the end, may be overkill, but I'll use them anyway. Since I don't know vb, I'll just describe how one might do this.
    Start by taking that initial loop you have, and at the start of it, the first thing you should do is call a function, subroutine, procedure, or whatever, I'll use function for the moment, and pass the current paddle location to it. It will return the new location.
    In this function, simply check for a keypress or whatever you use to move the paddle, and calculate the new paddle location, then return that value.
    Then have the loop do whatever else you need to do, and probably put a bit of a delay at the end of it, so it isn't insanely fast.
    Also note that, I believe, vb is a scripting language, and as such, has a significant amount of overhead just decoding the script. I like assembler, none of the wastefulness of a high level language or scripted language, but it's not necessary, or even recommended by most people.

    : Hi,
    : How exactly would i cause it to sleep and what kind of thread do you mean?
    :
    : THX
    : Dhruv(BattleGuard)
    :
    :
    :
    : : What you need to do is set up multiple threads, at least one to for the loop and another to handle user input. I am suspecting the reason you are having a problem is that the loop runs continuously and never stops and looks to see if the user has attempted to move the paddle. You can set up a thread and cause it to sleep for a small amount of time, in that time the other thread can update the paddle position, then sleep and go back to the loop. If this does not help just post again.
    : :
    : : : Hi,
    : : : Thanx for the response but i am currently only focusing on VB.Net. I am actually very new to programming and game graphics adn pc graphics. I am also learning a little 3ds max 4.I am only 12 years old, after all. I don't want you to think that i am dumb or i won't understand or anything. I am good with logic and stuff.
    : : :
    : : : Thx for the response
    : : : Dhruv(BattleGuard)
    : : :
    : : :
    : : :
    : : : : : Hi World,
    : : : : : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    : : : : :
    : : : : :
    : : : : : THX
    : : : : : Dhruv(BattleGuard)
    : : : : :
    : : : : :
    : : : : check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
    : : : :
    : : :
    : : :
    : :
    : :
    :
    :

  • BattleGuardBattleGuard Posts: 166Member
    Hi,
    Have you made any games like pong or something in assembler? I really don't want to learn ASM because it is a too complicated language for a 12 year old (me). I want to stick to .NET. Thanx for the response. I tried your idea and it got the paddle moving but i still need a few things particularly for VB.Net like how to define the events for keys (-> , <-) If you canhelp me with that it would be great. I have never made a game before and i am looking forward to making a few more. I still have to debug and fix the pong game before i can move forward.


    THX for the response
    Dhruv(BattleGuard)


    : Threads are overcomplicating a simple problem, and add a good amount of overhead. Even seperate functions, subroutines, or procdures, which are all the same thing in the end, may be overkill, but I'll use them anyway. Since I don't know vb, I'll just describe how one might do this.
    : Start by taking that initial loop you have, and at the start of it, the first thing you should do is call a function, subroutine, procedure, or whatever, I'll use function for the moment, and pass the current paddle location to it. It will return the new location.
    : In this function, simply check for a keypress or whatever you use to move the paddle, and calculate the new paddle location, then return that value.
    : Then have the loop do whatever else you need to do, and probably put a bit of a delay at the end of it, so it isn't insanely fast.
    : Also note that, I believe, vb is a scripting language, and as such, has a significant amount of overhead just decoding the script. I like assembler, none of the wastefulness of a high level language or scripted language, but it's not necessary, or even recommended by most people.
    :
    : : Hi,
    : : How exactly would i cause it to sleep and what kind of thread do you mean?
    : :
    : : THX
    : : Dhruv(BattleGuard)
    : :
    : :
    : :
    : : : What you need to do is set up multiple threads, at least one to for the loop and another to handle user input. I am suspecting the reason you are having a problem is that the loop runs continuously and never stops and looks to see if the user has attempted to move the paddle. You can set up a thread and cause it to sleep for a small amount of time, in that time the other thread can update the paddle position, then sleep and go back to the loop. If this does not help just post again.
    : : :
    : : : : Hi,
    : : : : Thanx for the response but i am currently only focusing on VB.Net. I am actually very new to programming and game graphics adn pc graphics. I am also learning a little 3ds max 4.I am only 12 years old, after all. I don't want you to think that i am dumb or i won't understand or anything. I am good with logic and stuff.
    : : : :
    : : : : Thx for the response
    : : : : Dhruv(BattleGuard)
    : : : :
    : : : :
    : : : :
    : : : : : : Hi World,
    : : : : : : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    : : : : : :
    : : : : : :
    : : : : : : THX
    : : : : : : Dhruv(BattleGuard)
    : : : : : :
    : : : : : :
    : : : : : check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
    : : : : :
    : : : :
    : : : :
    : : :
    : : :
    : :
    : :
    :
    :

  • korkor Posts: 198Member
    : Hi,
    : Have you made any games like pong or something in assembler? I really don't want to learn ASM because it is a too complicated language for a 12 year old (me). I want to stick to .NET. Thanx for the response. I tried your idea and it got the paddle moving but i still need a few things particularly for VB.Net like how to define the events for keys (-> , <-) If you canhelp me with that it would be great. I have never made a game before and i am looking forward to making a few more. I still have to debug and fix the pong game before i can move forward.
    :
    :
    : THX for the response
    : Dhruv(BattleGuard)
    :
    :
    : : Threads are overcomplicating a simple problem, and add a good amount of overhead. Even seperate functions, subroutines, or procdures, which are all the same thing in the end, may be overkill, but I'll use them anyway. Since I don't know vb, I'll just describe how one might do this.
    : : Start by taking that initial loop you have, and at the start of it, the first thing you should do is call a function, subroutine, procedure, or whatever, I'll use function for the moment, and pass the current paddle location to it. It will return the new location.
    : : In this function, simply check for a keypress or whatever you use to move the paddle, and calculate the new paddle location, then return that value.
    : : Then have the loop do whatever else you need to do, and probably put a bit of a delay at the end of it, so it isn't insanely fast.
    : : Also note that, I believe, vb is a scripting language, and as such, has a significant amount of overhead just decoding the script. I like assembler, none of the wastefulness of a high level language or scripted language, but it's not necessary, or even recommended by most people.
    : :
    : : : Hi,
    : : : How exactly would i cause it to sleep and what kind of thread do you mean?
    : : :
    : : : THX
    : : : Dhruv(BattleGuard)
    : : :
    : : :
    : : :
    : : : : What you need to do is set up multiple threads, at least one to for the loop and another to handle user input. I am suspecting the reason you are having a problem is that the loop runs continuously and never stops and looks to see if the user has attempted to move the paddle. You can set up a thread and cause it to sleep for a small amount of time, in that time the other thread can update the paddle position, then sleep and go back to the loop. If this does not help just post again.
    : : : :
    : : : : : Hi,
    : : : : : Thanx for the response but i am currently only focusing on VB.Net. I am actually very new to programming and game graphics adn pc graphics. I am also learning a little 3ds max 4.I am only 12 years old, after all. I don't want you to think that i am dumb or i won't understand or anything. I am good with logic and stuff.
    : : : : :
    : : : : : Thx for the response
    : : : : : Dhruv(BattleGuard)
    : : : : :
    : : : : :
    : : : : :
    : : : : : : : Hi World,
    : : : : : : : I am making a pong game(gasp!). I got the ball, paddle and the code in my head. The problem is that i have a loop for the thing that when the ball reaches a certain point, the program checks if the paddle is there or not. If the paddle is not there a msgbox appears. If it is there then the ball starts moving back towards the other way. But i can't move the paddle at all because a loop is already going on. Can anybody help me fix this or can anybody give me an alternate for this kind of game.
    : : : : : : :
    : : : : : : :
    : : : : : : : THX
    : : : : : : : Dhruv(BattleGuard)
    : : : : : : :
    : : : : : : :
    : : : : : : check for paddle movement and calculate that, probably through a function (in c) or a subroutine (in assembler) or anything similar, inside the loop.
    : : : : : :
    : : : : :
    : : : : :
    : : : :
    : : : :
    : : :
    : : :
    : :
    : :
    :
    :
    It's a common misconception that assembler is complicated. It is less complicated than most hll's. You only need to memorize a few (relative to the number of functions you can find in a few libraries) instructions, and keep track of how the data's changing. Good labels help that. You don't even need to keep track of the addresses of anything anymore. Check out nasm, at sourceforge.net/projects/nasm, and search excite for nasm documentation, you'll get a couple instruction set hits. Also, assuming you're using dos, search for ralph brown's interrupt list. It's a lot nicer than most people would suspect, and you get more control over how things work.
    As for having written games in assembler, no, actually, I haven't, but I'm working on a space engine for a mud. I also use unix, instead of dos/win, so I program for it. It's far superior, the syscalls are much nicer than dos interrupts. Only problem I've had is getting graphics to the screen, but glade's helping me with that.
Sign In or Register to comment.