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.

Newcomers DBPro Corner / My first 'game'

Author
Message
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 10th Jan 2011 06:07 Edited at: 10th Jan 2011 20:34
I downloaded DBPro the other day and have been messing with it a bit. I played with the tutorials some (it's a shame this laptop is such a weenie, some of the examples crash). At any rate, it's been DECADES since I did any programming to speak of, and that was with BASIC back in the good ol' glory days of the TRS-80 Model 4. Upside is this doesn't seem totally alien to me.

A couple of days of fooling around has resulted in this, my first 'game'. It's pretty rough, but it seems to work as far as it goes. What I'd like is some feedback on cleaning up the code, optimizing it, and so forth. I've got some ideas on how to expand it, but I want to polish what I've got before I move on to bigger and better things.

EDIT: Yikes, I sure messed up this first post (sorry, not used to this style of posting..yet).

Anyway, the folder in the attached zip file needs to be in the C:\Program Files\The Game Creators\Dark Basic Professional\Projects folder for the background I'm using to work> I haven't yet figured out how to set a relative path yet. Just in case the zip file doesn't come through (not sure yet what the guidelines are), here's the actual code. Just comment out Line 83 and a missing background won't be a problem.

Attachments

Login to view attachments
T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 10th Jan 2011 13:24
Quote: "What I'd like is some feedback on cleaning up the code, optimizing it, and so forth."


if you dont show some code, we cant give feedback...
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 10th Jan 2011 20:35
I've edited the original post, sorry for the mess-up *sheesh*
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 10th Jan 2011 20:40
*sheesh* Natch I gotta fight with a flaky internet connection as well.

The actual code (3rd try's the charm, I hope).

Rem ***** Included Source File *****
//Match pairs of same-colored squares
//Level 1 is a 2x4 grid

SET DISPLAY MODE 800,600,16
SET TEXT FONT "Verdana"
RANDOMIZE TIMER()
GLOBAL Rows=4 //Number of Columns in Level 1
GLOBAL Columns=4 //Number of Rows in Level 1
GLOBAL GridRow //Which Row the tile is on
GLOBAL GridColumn //Which Column the tile is on
GLOBAL GameLevel=1 //Game starts at Level 1
GLOBAL TileOffset=150 //Initial tile spacing
GLOBAL TileSize=100 //Initial size of tiles (100x100)
CLS
START:
GOSUB _GameStart
DO
DIM Grid(Columns,Rows) //Array that holds tile locations for the game level
GOSUB _ClearScreen
GOSUB _LoadLevel
GOSUB _PlayLevel
UNDIM Grid()
LOOP
END

_PlayLevel:
FirstColor$=""
SecondColor$=""
REPEAT
WAIT MOUSE
SELECT MOUSECLICK()
CASE 1
ResetHint()
IF FirstColor$=""
FirstColor$=STR$(RGBR(POINT(MOUSEX(),MOUSEY())))+STR$(RGBG(POINT(MOUSEX(),MOUSEY())))+STR$(RGBB(POINT(MOUSEX(),MOUSEY())))
ELSE
SecondColor$=STR$(RGBR(POINT(MOUSEX(),MOUSEY())))+STR$(RGBG(POINT(MOUSEX(),MOUSEY())))+STR$(RGBB(POINT(MOUSEX(),MOUSEY())))
IF FirstColor$=SecondColor$
INC GameLevel
INC Rows,2
INC Columns,2
TileSize=TileSize*.75
TileOffset=TileOffset*.75
RETURN
ELSE
FirstColor$=""
ENDIF
ENDIF
ENDCASE
CASE 2
ResetHint()
ENDCASE
ENDSELECT
UNTIL ESCAPEKEY()
RETURN

_LoadLevel:
SET TEXT OPAQUE
SET TEXT SIZE 15
INK RGB(255,255,255),RGB(255,0,0)
CENTER TEXT 399,0,"LEVEL "+STR$(GameLevel)
Populate()
RETURN

_GameStart: //Drawn at the top of each game board
GOSUB _ClearScreen

SET TEXT OPAQUE
INK RGB(255,0,0),0
SET TEXT SIZE 30
CENTER TEXT 399,5,UPPER$("Match pairs of the same color as fast as you can!")
CENTER TEXT 399,100,"GAME CONTROLS:"
CENTER TEXT 399,135,"Left-click to select tiles and buttons."
CENTER TEXT 399,170,"Right-click to display RGB value at mouse location."
SET TEXT SIZE 60
CENTER TEXT 399,250,"Left-click to start game!"
WAIT MOUSE
RETURN

_ClearScreen:
CLS
LOAD BITMAP "C:\Program Files\The Game Creators\Dark Basic Professional\Projects\MatchGame\Leather3.jpg",0
RETURN

FUNCTION ResetHint()
SET TEXT SIZE 15
SET TEXT OPAQUE
INK RGB(255,255,255),RGB(0,0,255)
SET CURSOR 0,0
PRINT " "
SET CURSOR 0,0
PRINT "RGB("+STR$(RGBR(POINT(MOUSEX(),MOUSEY())))+","+STR$(RGBG(POINT(MOUSEX(),MOUSEY())))+","+STR$(RGBB(POINT(MOUSEX(),MOUSEY())))+")"
ENDFUNCTION

FUNCTION PickColor() //Randomly generates INK color
R=RND(254+1)
G=RND(254+1)
B=RND(254+1)
INK RGB(R,G,B),0
ENDFUNCTION

FUNCTION Populate() //Draws the squares
HIDE MOUSE
Pairs=Rows*Columns/2
FOR Cycles=1 TO Pairs
PickColor()
CheckLocationClear()
BOX GridColumn*TileOffset+30,GridRow*TileOffset+30,GridColumn*TileOffset+TileSize+30,GridRow*TileOffset+TileSize+30
CheckLocationClear()
BOX GridColumn*TileOffset+30,GridRow*TileOffset+30,GridColumn*TileOffset+TileSize+30,GridRow*TileOffset+TileSize+30
NEXT
SHOW MOUSE
ENDFUNCTION

FUNCTION CheckLocationClear()
DO
GridRow=RND(Rows-1)
GridColumn=RND(Columns-1)
IF Grid(GridColumn,GridRow)=0
Grid(GridColumn,GridRow)=1
EXIT
ENDIF
LOOP
ENDFUNCTION
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 11th Jan 2011 02:25 Edited at: 11th Jan 2011 02:35
Neat, I am amused by this little game! I'm impressed to see this from a returning beginner.

Hi Trucker, and welcome back to the world of code!

This is the sort of thing I am trying to teach my current 'disciple'... something simple and practical to learn the necessary skills required to make something more substantial.

It works just fine on my machine, and demonstrates exactly the right entry-level skills I believe are necessary to enter our world.

The first thing that jumps out at me is code readability. As a new re-entry into coding, I suggest that you start indenting your code iteratively. All code between a DO and its married LOOP should be intended one TAB. Take the last function of your code for example (CheckLocationClear). Indent everything between the DO and the LOOP with one TAB. Then, further indent everything between the IF and the ENDIF with a second TAB. It makes reading your code far easier.

Try to avoid the EXIT command. I'm going to teach this one in steps to make it easier to see why we're doing it:

In the same function CheckLocationClear(), clear a flag to 0 before the DO:

quitflag = 0

Now, replace the EXIT command with one to set the flag:

quitflag = 1

Then, between the ENDIF and the LOOP commands, abort the loop if the flag has been set, like so:

IF quitflag = 1 THEN EXIT

This gives you the same effect, but now we're using a flag to initiate the abort instead of doing it within an IF statement (which has never been ENDIF'd because you EXIT before we reach that command, creating stack problems later).

It shouldn't be difficult to understand the new logic I've set up here, but I wanted you to see the use of the flag before I move on to the next step:

Replace the DO...LOOP 'unconditional' iteration with a REPEAT...UNTIL 'conditional' iteration by changing the DO into REPEAT and the LOOP into UNTIL.

Now, the UNTIL command requires a condition upon which to abort the loop (which is why it is called a 'conditional' loop), so the line becomes:

UNTIL quitflag = 1

This is our final version of the function. It's much cleaner, avoids the stack problem of never ENDIF'ing an IF, and avoids the EXIT command entirely, which is a horrible, horrible command to get used to using for a billion reasons. For clarity, here is the final version of CheckLocationClear():



[EDIT]: After typing all that out, I see that you already know how to use REPEAT...UNTIL as you have done elsewhere in your code. Forgive my assumption otherwise, but I'm going to leave my explanation in this post for the benefit of others.

The moral of the story is, never use the EXIT command - always use a 'conditional' loop with a flag to determine when to abort.

The function Populate() uses an 'unspecific' FOR...NEXT loop. This is fine as it stands, but it's good practice to specify which FOR you're NEXTing in case you nest your loops in the future. Use:

NEXT Cycles

Instead of just:

NEXT

The effect is the same, but it's 'specific' now, which is just good practice and also makes it easier to read when you start nesting loops (loops within loops within loops).

In function PickColor(), you've made a logic error in your random number generation. There's no point in structuring this command the way you have:

R=RND(254+1)

Because the argument (254+1) is evaluated before function (RND) the 1 will be added to the 254 before the final result of 255 is used in the RND command. You may therefore just as well be using:

R=RND(255)

I can plainly see, however, that your intent is to avoid the selection of a zero value. The way to do that is thus:

R=RND(254) + 1

The addition needs to be outside the RND function so that the RND takes place before we add one to the result, otherwise a zero will always be possible. You also need to reduce your maximum value by one (we use 254 instead of 255) because we're going to add one to it afterwards, and we don't want a value of 256. This should be easy enough to follow.

It's a little more complicated, but you could reduce the entire function to a single line, one that eliminates the need for variable assignment:

INK RGB(RND(254) + 1, RND(254) + 1, RND(254) + 1), 0

If you don't immediately see why, that's ok, your original logic works just fine.

Now that we see how to use RND to avoid a zero, go back to CheckLocationClear() and have another look at your RND's. You're going to get zero results here sometimes. With the code the way it stands that doesn't matter, since zeroes are allowed as array indices and you're only using that array to check that a box hasn't already been matched to a pair (really inefficient, but we'll get to that). This means that the box in the top left corner of the field is at array position 0, 0 and not at position 1, 1. That's well and good, as long as you're aware of it - I find a lot of people get confused by the first element of an array being 0 and not 1. If you ever use your Grid array for anything more than merely checking for duplicate pairs (such as storing what color the box is, which we'll do later), you'll need to remember that topleft is 0, 0 and the bottomright is Columns-1, Rows-1.

In ResetHint() I don't see the purpose of these lines:

SET CURSOR 0,0
PRINT " "

Immediately followed by:

SET CURSOR 0,0
PRINT <complex string>

Unless I'm missing something, I think you can do away with the first SET CURSOR and PRINT command altogether, as they don't seem to do anything.

As to relative pathing, it works like this:

LOAD BITMAP "Leather3.jpg", 0

This command will load the file from wherever the executable is, and if you move that executable someplace else you will also have to move the image file to the same folder, as the code will look in that new location for the image file.

LOAD BITMAP "GFX\Leather3.jpg", 0

This one will look for the image file in the folder "GFX" that lies in the same folder as the executable. If you move the executable, you also have to move the folder that contains the image file.

You've used SET TEXT OPAQUE any number of times throughout the code. You only need to do this once (do it right at the top of the initialisation code, immediately below your SET TEXT FONT command). If you ever used SET TEXT TRANSPARENT you'd need to set it back to opaque again later, as needed, but unless you set the text away from opaque you don't need to repeat yourself. DBPro's native text commands are insanely sloooooow so always use as barebones few of them as you possibly can.

I'm curious about your use of GOSUBs when you clearly have a solid understanding of how to operate functions. You'll have to forgive me, but I'm flat out tired of arguing why the use of GOSUB and GOTO is simply incorrect programming. You'll find the argument all over any programming forum: Change all of your GOSUBs into functions and don't ever type the characters GOSUB or GOTO again You can keep the labels to which they refer if you like as they help to identify different parts of your code and they're ignored by the compiler anyway, though I'd rather see REM's as a matter of practice.

The only other thing that jumps out at me is spacing. Take a look at these two lines of code, the first being yours and the second being my adjustment to it:

TileSize=TileSize*.75

TileSize = TileSize * .75

It's just a little easier to read. Here's another example in which it makes a far greater difference to code readability:

FirstColor$=STR$(RGBR(POINT(MOUSEX(),MOUSEY())))+STR$(RGBG(POINT(MOUSEX(),MOUSEY())))+STR$(RGBB(POINT(MOUSEX(),MOUSEY())))

FirstColor$ = STR$(RGBR(POINT(MOUSEX(), MOUSEY()))) + STR$(RGBG(POINT(MOUSEX(), MOUSEY()))) + STR$(RGBB(POINT(MOUSEX(), MOUSEY())))

As in written English, put a space after every comma, and around each operator like a plus sign. Code readability is a big issue when asking others to review your code, and also helps with your own debugging as each 'term' is made distinct to the eye.

Overall a solid effort for a returning programmer after an extended hiatus. Not many new guys can produce something like this on their first shot. Please accept my encouragement and continue on the good road back into our world!
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 11th Jan 2011 07:50
Thanks very much, this is just the sort of thing I was hoping to get back. On the subject of indenting, it IS indented on my machine. Apparently I messed up the code snippet addition. Clicking the 'code' button in the forum message box puts "" before the snippet but not after. I suspected it needed that after the snippet as well, but I wasn't sure.

The purpose behind the complexity of the ResetHint function is a way of clearing the text in top left corner. Actually, there are many more whitespaces in between the " ". I found that if I didn't do that and a new string was shorter than the one before, the end of the old one would still be visible (it's essentially a cludgy workaround to keep the hint box ungarbled).

The many SET TEXT OPAQUEs are a leftover of previous versions...when there was a combination of transparent and opaque text.

I understand that the first element of an array is 0. CheckLocationClear actually has nothing to do with pairs, it merely checks to see if a place on the grid has been used already. If that location has a tile, the flag gets set to 1. I originally had a FUNCTION ClearLocation that would set all the elements of the array back to 0 (before I realized that simply DIMing the array in the main game loop and UNDIMing it there made more sense).

On the subject of GOSUB vs FUNCTION, for some reason I was thinking it was more proper. The notion had occurred to me that they were doing the same thing. I'll check through the programming forum, but I suspect using GOSUB means the machine has to search through all the lines of code to find the routine whereas using FUNCTION tells it immediately where it is? I noticed that a FUNCTION() call is automatically highlighted in the editor whereas GLOBAL _XXX isn't.

I'll clean up the code as you've suggested and see if I can break it *grin*.

On thing I really NEED to do is figure out a more efficient method of populating the grid. This way works, but as the grid size expands it naturally gets exponentially slower...although my original vision of the game wasn't to have the grid size expand indefinitely. This is just to get something working to check the concept.

Thanks again!
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 11th Jan 2011 07:55
As an aside, I haven't figured out how to compile this thing to an exe. Can I even do that using DBPro? bear in mind I'm using the free download version. I've been running this straight from the DBPro editor, so using anything but an absolute path hasn't worked for me (yet).
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 11th Jan 2011 15:54 Edited at: 11th Jan 2011 16:08
DBPro is capable of creating executables, and I remember back before I purchased a full working version and I was playing with the demo, that also produced executables that displayed a DBPro watermark right before it started execution of your program. Perhaps the demo has changed since then (that was seven years ago) but look around the IDE a bit to see if you can figure it out.

GOSUBs and GOTOs are kind of a faux pas among us codemonkeys; If a function is the aristocrat of the group, then GOSUB is the common peasant and GOTO is the little street urchin thieving people's stuff - both unwelcome in civilised company

It's never proper to use either one of them. I can't think of a single situation in which the solution requires a GOTO or where a GOSUB achieves something a function does not. Their use is pathway to lazy, inefficient programming habits, so any code that will be called more than once should be in a function. GOSUBs can create stack overflows if you are slack in pairing up RETURNs properly. This becomes a real problem when you are nesting GOSUBS, and becomes virtually impossible to manage when you start creating recursive GOSUBs. The problem is eliminated entirely if you just stick with functions, which can recurse almost indefinitely without worrying about the stack. As an added incentive, most IDE's these days will collate functions for you under a heading to one side, so you can easily doubleclick them to jump to them in your code.

I see what you've done with ResetHint(). I did notice that shorter hints after longer ones looked messy when I compiled your code, but that is of course because all the whitespaces didn't transfer properly. I suppose this is as good a method as any to keep it clean. It only works if you set a background color though, as you have, since whitespaces don't actually draw to the foreground.

I understood the function of CheckLocationClear right away. The reason it becomes so slow has to do with your random number generation technique to determine where to put pairs. The more pairs you place, the fewer grid locations are still "clear" locations, so the program has to guess more and more frequently as more and more pairs are made, hitting locations that have already been paired up and having to try again. When it gets to the last pair, we have to wait all day for it to keep guessing over and over again until it flukes it into hitting the last two available locations. The larger the grid is, the number of times it has to guess before it hits those last two locations becomes, as you said, exponentially higher.

I think that the most efficient way to populate the grid is to create two more arrays, one with a size equal to Rows and the other with a size equal to Columns (or use a single, two dimensional array). Fill these arrays with the numbers 1 through Rows, and 1 through Columns. Then scramble these arrays (I can show you how to do this if it doesn't come to you easily). Now run through the arrays, using their contents as coordinates. Take element one from each array, and draw a box of your chosen color at the coordinates specified by those elements. Then take element two from each array, and draw a box of the same color at those coordinates. Now pick a new color, and move on to the next element pair. Once you've run through the entire array, your grid is completely populated. This method eliminates the "hit and miss" that's causing your slowdowns as the grid gets larger.

See how you go turning that into code, or if you have a better idea I'd love to see it!
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 13th Jan 2011 23:42
I've come up with a MUCH faster way to randomize the grid. The attached zip file is straight out of my projects folder.

Quick question, why is it that it runs just fine when the dba is compiled and run through DBPro, but the exe file crashes when it tries to load the bitmap?

Attachments

Login to view attachments
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 14th Jan 2011 00:32
The randomisation code seems reasonable. I'm not a fan of the ARRAY INSERT AT <location> set of commands, simply because I'm oldschool and like to handle my array manipulation manually. and those commands are a little bit buggy, but the logic is sound. It's much better than the hit and miss game you were playing before.

The bitmap command fails because you are using the wrong command - I wasn't sure what you had intended with the command earlier, but I think you just want to use LOAD IMAGE and then later on, when you clear your screen, use PASTE IMAGE.

The LOAD BITMAP command is failing because of your relative path usage - the code can't find the file. When I supply the file to the correct location (which isn't where you'd think), it runs just fine (though just loading the bitmap doesn't do anything - you've never taken any action with the bitmap in your code, so it never gets displayed or anything).

Try a little test for me: Find the TEMP folder in your DBPro install: c:\Program Files\DarkBasic Pro\TEMP or somewhere similar. Make a Graphics folder there, and stick your jpg file in there. I know this location has nothing immediately obvious to do with your project, but just see if it'll run when you do that (I'm working in godly ways behind the scenes here!) Let me know whether or not this works, and the answer will let me help you get it working the way you expect.
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 14th Jan 2011 00:45
There is no temp folder in the location you specified. I did find a temp folder in C:\Documents an Settings\....\Local Settings\Temp\Dark Basic Professional TEMP.

Putting the folder there didn't do anything.

As an aside, what method would you have used to randomize things?
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 14th Jan 2011 00:48
Also, oddly enough, that jpeg works just fine when the dba is compiled and run within DBPro - why would it be so different when run from the exe?
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 14th Jan 2011 01:34
Quote: "The randomisation code seems reasonable. I'm not a fan of the ARRAY INSERT AT <location> set of commands, simply because I'm oldschool and like to handle my array manipulation manually."

random interjection here, but I think that the DBPro array commands are actually pretty marvelous. I believe there's a distinction whether an array is fixed, a list, or a stack, and each command behaves differently depending on what you're doing (dynamically typed?). I think IanM or someone else would know a lot more, but I like DBPro arrays a lot.

Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 15th Jan 2011 00:57
Everybody likes arrays, but but to give you a simple example of why they are buggy, use ARRAY COUNT on an array whose size you've hardcoded.

Look at this code:

DIM array(10)
PRINT ARRAY COUNT(array())

The output will be ten, when it should be eleven - the command doesn't count element zero. Little bugs like this make me distrustful of the inbuilt array commands. I prefer to manipulate my arrays manually.

Trucker, I can't get the JPG to work either from within the IDE or when manually executing the EXE (it's the same thing anyway, the IDE compiles and runs the exe every time you test). Does it work if you use an absolute path?

I described the logic I'd use to randomise the grid in an earlier post. I'm in a rush right now so I can't type it out again - look in the post immediately above yours in which you said you've found a much faster way. Your way is just as good as mine, I just don't like the array commands. Personal preference.
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 15th Jan 2011 01:12
The jpg works fine here from within the IDE, using either a relative or absolute path. From the exe it only works using an absolute path.

Hmmm....I already ran into that ARRAY COUNT bug (I just thought I did something wrong). The following code snippet is what I came up with to avoid the null spaces from DIMing the list array, before adding the actual colors to the list.



Originally I'd intended to go through the list and delete the original null spaces, but it never worked right due to using a FOR/NEXT loop with ARRAY COUNT. The above way works better anyway.
digital trucker
13
Years of Service
User Offline
Joined: 9th Jan 2011
Location:
Posted: 15th Jan 2011 06:03
Allright, this is driving me nuggin' FUTZ.

DarkBASIC Professional Editor: Build 8 2009
DarkBASIC Professional Compiler: Version 1.071

Downloaded/installed a few days ago or so. I got it to compile an exe ONCE. It wasn't very easy to do, and now I can't get the thing to compile an exe again. Help files are slightly mismatched to what the actual menus say. Could someone please define the exact process to produce an exe from a dba?

On the subject of the malfunctioning jpg, I think I know the solution, but until I can reliably create/update an exe file I'm kinda stuck in limbo.
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 15th Jan 2011 15:50
I don't use the default IDE (Synergy) because I've replaced it with Codesurge, which I think is a better environment (just personal preference). However, I'm 99% sure that in just about every environment available for DBPro, including Synergy, hitting F5 on the keyboard compiles an EXE and runs it.

You seem to be missing the fact that every time you run your code, an EXE is generated, and that EXE is what you're seeing run. IDE's these days don't work like the ones back in your day - there's no such thing as an 'Interpreter' in 2011. We use 'Compilers', which make EXE's. Every time you run your code, it's compiled into an EXE, and that EXE is what gets run when you see your code in action. There is no difference whatsoever between running properly configured project code from the IDE, and running the executable itself.

Therefore, if you're experiencing a discrepancy in operation between hitting the EXE manually and "running the program from the IDE", then I would submit you are using 'projects' incorrectly. Are you using a project file at all? When you open up your program to start working on it, do you click on a file with an extension of .dba or .dbpro? If you're clicking on a .dba file, that's your problem: you're not using projects properly.

When you compile code that isn't in a project (ie, a .dba file), the EXE goes into a TEMP folder (which you said doesn't exist - very confusing) and the code is run from there, which will screw up your file path relativity. If you compile code that is in a project, relativity should be retained and the problem you describe shouldn't happen.

If you are already using a properly configured project (that is, a .dbpro file) then unfortunately I can't tell what the problem could be. It will be something in the configuration of the project that you're overlooking that comes naturally to an experienced DBPro operator but doesn't come naturally to a new guy, which is why I can't anticipate it (does that makes sense?). If you are using a .dbpro file to open your program, then I want you to zip up your entire project folder and attach it to your reply post so I can take a look at it. If you are using projects and there's something wrong with its configuration it should jump out at me instantly when I open it up.

If you're not using projects, create a new one (look in the File menu of the IDE), and copypaste your code into it. Then save the project and from then on, use the .dbpro file to open your code, and not the .dba file. This should solve your path relativity problems.

Let me know how you go.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2011 18:05 Edited at: 19th Jan 2011 18:05
I just saw this message and want to welcome you back to programming Digital Trucker.

Did you get your .exe to run properly yet? I noticed when downloading the last version in the .dbpro file you don't have .exe on the filename it creates. Add that and recompile with (as Agent said) a Graphics folder with leather3.jpg in it (see attached image).

I played the game all the way to level 15 where the boxes disappear from sight. There needs to be a "Congratulations! Here's how long it took you." after level 14. When I got to 15 I also discovered that you can cheat by clicking twice in the red of the Level text. The area the actual POINT() is detected needs to be limited to the colored box area.

Attachments

Login to view attachments
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 20th Jan 2011 00:23
Lol! You dirty little cheater I never thought of that.

I wonder how he's going with getting executables to work properly.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Jan 2011 07:45
Hahaha thanks. It really works everywhere (background too) if you don't move the mouse at all or just click somewhere in the same box.

Hopefully he hasn't given up on Darkbasic Pro... it's been 5 days since his last post.

Login to post a reply

Server time is: 2024-11-23 03:30:37
Your offset time is: 2024-11-23 03:30:37