Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Weird Text Adventure Problem

Author
Message
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 11th Aug 2010 20:55
So Im just passing the time programming a text adventure but It keeps crashing whenever it gets to an input. Here is the code



Also, this is to help with a different, larger progect, but how do you make 2d collision? Thanks.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th Aug 2010 21:10
Couldn't re-create the crash, but my guess is that its because you didn't put a variable into your INPUT command. The syntax for input is:

INPUT Variable
INPUT Message$,Variable

The variable is where the user's answer is stored.

As far as 2d collisions, you would want to use sprites. Check out some of the examples, but here are the commands you would probably be using

SPRITE
SPRITE HIT
SPRITE COLLISION

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 11th Aug 2010 22:07
Quote: "
Couldn't re-create the crash, but my guess is that its because you didn't put a variable into your INPUT command. The syntax for input is:

INPUT Variable
INPUT Message$,Variable

The variable is where the user's answer is stored.

As far as 2d collisions, you would want to use sprites. Check out some of the examples, but here are the commands you would probably be using

SPRITE
SPRITE HIT
SPRITE COLLISION
"


1. ? So where would I put that? Like before the message?

2.Damn't. So I just built a whole maze for nothing?
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Aug 2010 22:07
You could use WAIT KEY instead of WAIT 1000000000. KEY isn't a variable, WAIT KEY is a separate command that waits for you to press any key before continuing.

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th Aug 2010 22:47
Quote: "1. ? So where would I put that? Like before the message?"


You would put it after the message, like so:

INPUT "Press A, B or C",optionchosen$

Whatever the player enters will now be stored in the string variable that I made called optionchosen$. Keep in mind, if you leave out the $ symbol, it is just an integer variable and cannot handle letters

2. No, sprites are ways of displaying 2d pictures. The maze you made can be used as a sprite.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 11th Aug 2010 22:57
for 2 I mean , I made the lines into a maze like line, 10, 21, 20, 21 (not actual line), is there a way to make collison on the actual line?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th Aug 2010 23:17
ah, well you could use GET IMAGE to grab it, then make a sprite. But without some more interesting math, there is no way to just check for collision with a line.

Think of drawing commands just like drawing on paper. Once you draw them, you can't move them around on the paper and you can't really interact with it. Sprites are more like those old felt boards from back in preschool, where you can put a felt image onto any part of the board, then take it off and move it around.

Make sense at all?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 12th Aug 2010 00:43
It is starting too make sense, but I'm now thinking of a way that I can save my self from wasting the time i spent making the maze. Could I possibly make it so if the thing touches a certain color? If not. Damnit, here goes some sprite making.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Aug 2010 01:23
Don't worry, your maze wasn't a waste of time.

It goes something like this:



If you want to export the image, you can use GET IMAGE to grab the picture from the screen and then use SAVE IMAGE. After that you won't have to have the program draw it, you just need to load the image.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Aug 2010 02:30
Quote: "for 2 I mean , I made the lines into a maze like line, 10, 21, 20, 21 (not actual line), is there a way to make collison on the actual line?"

A sort of "poor man's" collision would be using the POINT command to check the color at a screen location. Not too hard to implement though.

if point(x,y) = some color then collision

But POINT automatically calls a SYNC (which redraws everything) each time it is used so it can really slow the program down if it is called too often or placed in a bad spot.

Enjoy your day.
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 12th Aug 2010 04:52
Quote: "Don't worry, your maze wasn't a waste of time.

It goes something like this:

+ Code Snippet
REM Draw Maze. Assume dimensions are 100x120
LINE 0,0,100,120

GET IMAGE 1,0,0,100,120

SPRITE 1,320,240,1


If you want to export the image, you can use GET IMAGE to grab the picture from the screen and then use SAVE IMAGE. After that you won't have to have the program draw it, you just need to load the image."


Okay. I think I got it. So I turn each line into a sprite then Import it as a sprite, and It will be able to detect collision?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Aug 2010 04:57
Quote: "turn each line into a sprite then"


No, you turn the entire maze into a single sprite. In dbc, you can check for collision with an image without counting the parts colored RGB(0,0,0). So you grab your whole maze in a single image, turn it into a sprite, and you can use SPRITE COLLISION to check for collision

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 12th Aug 2010 06:10
I didn't really notice that this was A DBC specific board. I thought this was an anything DB board. Does this work in DBP too?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Aug 2010 07:02
Well, no, dbpro doesn't support pixel perfect collision, last I checked. Basically in dbpro if you have a white line and all the rest of the sprite is black (even if its transparent), collision will still register in the black zones. In dbc, it only registered in non-black zones.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Aug 2010 11:35
Quote: "Well, no, dbpro doesn't support pixel perfect collision, last I checked. Basically in dbpro if you have a white line and all the rest of the sprite is black (even if its transparent), collision will still register in the black zones. In dbc, it only registered in non-black zones."

Really?... We... win?

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Aug 2010 11:46 Edited at: 12th Aug 2010 11:56
At least last time I checked (tried it a few years back and one of the DarkNOOBS confirmed recently but not sure if it was tried).

Turns out DBC is still good for something other than just being awesome.

[EDIT ~5min later]
Tested: CONFIRMED!
Sorry for the uncommented code, it should be self explanatory anyway.

Run this in DBC and DBP and you will notice a distinct difference, namely that in DBC, the small box will pass straight through the larger ones. In DBP, it will stop once it hits the black area in between it. Curiously enough, DBP seemed to put the background as blue, rather than black as I specified with INK and CLS.



Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
ghostkrashers
13
Years of Service
User Offline
Joined: 19th Jul 2010
Location:
Posted: 12th Aug 2010 20:19
Thanks. I get it now. It makes more sense now.

Login to post a reply

Server time is: 2024-04-18 17:19:34
Your offset time is: 2024-04-18 17:19:34