• Collision detection in QBASIC 1.1
    16 replies, posted
Hey guys, I've been trying to get extra credit points for Programming class, in which we do QBASIC 1.1. I have tried making a platform game, in which you jump from platform to platform. So far I have jumping down pack, but for collision detection I have no clue. I was thinking about using the POINT command, but I'm having a hard time getting that to work. If anyone can remember to their high school days and remember QBASIC to help me out, I'd be appreciated. If you want to see what I have done so far check this: [URL]http://www.mediafire.com/?m6wkqx2eg6dk5bc[/URL]
Why the hell are you using QBasic? I mean, seriously?
QBasic is seriously outdated and everything, no one should be using it any more. But even with that put aside, why would anyone use and outdated version of an outdated programming language? 4.5 is the most used one and 7.1 is the newest.
Programming class. They would use QBasic 0.5 if it existed.
[QUOTE=Blueridge;25693514]If you want to see what I have done so far check this: [URL]http://www.mediafire.com/?m6wkqx2eg6dk5bc[/URL][/QUOTE] Though I don't have anything with QBasic to run it on, I took a look at your program to see if I could make any suggestions based on the code, but it has no comments and isn't well-indented and I lost interest in trying to figure out what it's supposed to do. However, I see comparisons of a keystroke against W, A, S, and D, so presumably you're moving something around on the screen. I also see circles being drawn centered on (x, y). I don't see anything [i]else[/i] being drawn so it's not clear what you're trying to collision-detect against. If you just want to avoid hitting the edges of the screen, you can do that based on the center and radius of the circle. Your screen is 640x480 and your circle's radius is 5, so the minimum X and Y coordinates are both 5, the maximum X is 634, and the maximum Y is 474. You can check your x and y variables against those values to prevent the circle from going past them.
[QUOTE=Darwin226;25701799]QBasic is seriously outdated and everything, no one should be using it any more. But even with that put aside, why would anyone use and outdated version of an outdated programming language? 4.5 is the most used one and 7.1 is the newest.[/QUOTE] I was told that 4.5 was the oldest and 1.1 was the newest. Yeah, dunno how that works either. [editline]29th October 2010[/editline] [QUOTE=Wyzard;25721525]Though I don't have anything with QBasic to run it on, I took a look at your program to see if I could make any suggestions based on the code, but it has no comments and isn't well-indented and I lost interest in trying to figure out what it's supposed to do. However, I see comparisons of a keystroke against W, A, S, and D, so presumably you're moving something around on the screen. I also see circles being drawn centered on (x, y). I don't see anything [i]else[/i] being drawn so it's not clear what you're trying to collision-detect against. If you just want to avoid hitting the edges of the screen, you can do that based on the center and radius of the circle. Your screen is 640x480 and your circle's radius is 5, so the minimum X and Y coordinates are both 5, the maximum X is 634, and the maximum Y is 474. You can check your x and y variables against those values to prevent the circle from going past them.[/QUOTE] Yeah, I haven't remarked anything on that bit. I fixed the remarking yesterday or so. I wasn't sure how to make the level when I uploaded that. I probably should start of with designing the level, then adding collision detection to things I know will be the same.
Why would the lowest number be the newest version. That's alogical.
When they reach 0.0 everything explodes or something XD
Umm, that's actually correct, if you're talking about QuickBASIC. QBasic 1.0 was based on the earlier QuickBASIC 4.5. QuickBASIC 4.5 - 1988 QuickBASIC 7.1 - 1990 (7.1 is not really a new version of QuickBASIC itself, but an update to the Development System) QBasic 1.0 (different product) - 1991 QBasic 1.1 - 1994 The main difference between QuickBASIC and QBasic is that QuickBASIC actually has a compiler, which Microsoft removed in QBasic.
Go FreeBASIC instead..
Go Python instead...
Fuck off. If he is familliar with QBASIC, he should do FreeBASIC..
I'm sorry to bump such an old thread, but I know the pain of looking for an answer and finding a thread with none of them, and I found an answer to the question. the basic formula for 2d collision detection is : [code] if ABS(SubjectX-ObjectX) + ABS(SubjectY+ObjectY) < CollisionRadius then //collide else //no collision end if [/code] to turn this into a function, we declare it as an integer [code] Declare Function Collide(SubjectX as Integer, ObjectX as Integer, SubjectY as Integer, ObjectY as Integer) as Integer [/code] and then write the function at the bottom [code] Function collide(SubjectX as Integer, ObjectX as Integer, SubjectY as Integer, ObjectY as Integer) as Integer Return ABS(SubjectX - Objectx) + ABS(SubjectY-ObjectY) End Function [/code] then to implement it, if you want to compare two individual objects you simply need to add somewhere in the game loop: [code] if collide(playerX, enemyX, playerY, enemyY) < Some_Collision_radius then //collide else //don't collide, or simply leave this statement out if you want nothing to happen end if [/code] once again mods, very sorry to dig this up, but since it's my first result for "Qbasic collision detection", I felt it was my responsibility to publish what I found in case someone else had this problem edit: I did this in freebasic, which is based on qbasic/quickbasic. you might need to alter it a bit to fit your dialect. Unfortunately this doesn't really answer OP's question. You could split it in half to detect X and Y separately I think. Something like... [code] Declare Function CollideX(SubjectX as Integer, ObjectX as Integer) as Integer Declare Function CollideY(SubjectY as Integer, ObjectY as Integer) as Integer //... Function collideX(SubjectX as Integer, ObjectX as Integer) as Integer Return ABS(SubjectX - Objectx) End Function Function collideY(SubjectY as Integer, ObjectY as Integer) as Integer Return ABS(SubjectX - Objectx) End Function [/code] and then use it as: [code] if collideX(playerX, platformX)<platform_width then if collideY(playerY,platformY)<platform_height then //collide end if end if [/code] this would check a less perfect shape like a rectangle.
[QUOTE=proboardslol;44931390]once again mods, very sorry to dig this up, but since it's my first result for "Qbasic collision detection", I felt it was my responsibility to publish what I found in case someone else had this problem[/QUOTE] well then I should probably post my solution to that BCPL problem I had, just in case
Wow QBasic.. in my programming class we at least used Just Basic, no matter how shitty it was.
[QUOTE=sambooo;44935235]well then I should probably post my solution to that BCPL problem I had, just in case[/QUOTE] I think it's important to publish your results in case someone else has the same problem as you
[QUOTE=proboardslol;44937176]I think it's important to publish your results in case someone else has the same problem as you[/QUOTE] Which reminds me, I still have a few things to post :suicide: Not programming related for the most part, though.
Sorry, you need to Log In to post a reply to this thread.