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 / Halp! -Programming issues...

Author
Message
Rakansen
18
Years of Service
User Offline
Joined: 19th Jan 2008
Location:
Posted: 22nd Nov 2008 07:41 Edited at: 22nd Nov 2008 07:57
I am convinced this is not a user error... I've gone through the logic a hundred thousand times, and I don't understand what is wrong with my code. I'm using an older version of DB Classic, so maybe it's a bug. Perhaps there's a way around it? Well, long story short, I'm trying to create a very simple yu-gi-oh dueling game so I can duel my friends online. (I know, I'm truly the worst type of nerd...) This game will not be any more structured than real life, so cheating would be easy, but this is only for fun among friends, so I'm not too worried about that. I wanted something quick and simple to make.

So, in the very beginning of the program, I have to load all the card images. (data for each card will be inserted later) I have it set up so you can throw jpegs into a folder called "Cards", and the program will then go through and load all images in that folder...well it SHOULD. That's where the issues begin. What's wrong with my code?



Any and all help appreciated. -OP
Rakansen
18
Years of Service
User Offline
Joined: 19th Jan 2008
Location:
Posted: 22nd Nov 2008 08:53
Did my thread disappear for good just because I edited? O.o
Just in case, I'll post this before I go to bed then.

Code for loading a bunch of Yu-Gi-Oh card images:


Dark Basic says: "ur doin it wrong"
I don't know why...
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Nov 2008 11:03
I saw this in post approval - basically, the problem is your code.

Instead of trying to load something, print the filename to the screen. Then ask yourself what it means to load "." and "..".

Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 22nd Nov 2008 17:49
Whenever you do a checklist for files, the first two items in the checklist are always "." and "..". I don't know what the difference between them is, but they both link to the parent folder (it's like clicking to go "up one level" in the Windows file browser).

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Rakansen
18
Years of Service
User Offline
Joined: 19th Jan 2008
Location:
Posted: 22nd Nov 2008 19:40
Thanks! You were both a big help. According to DB, I'm able to load the images using this code:

However, "paste image 1,150,150" will not work. It says the image does not exist. :S So something must still be wrong...
steve paul thomas
17
Years of Service
User Offline
Joined: 4th Nov 2008
Location: United Kingdom
Posted: 22nd Nov 2008 21:25 Edited at: 22nd Nov 2008 21:32
@Rakansen

Both IanM and Robert The Robot have valid points. You do have the right idea though, since . and .. are the first two elements in the checklist, skip the first two and start at 3:




Also, another useful technique is to get the path of where the program is running from. Try this program out. It gets the path where the program is running from, prints it and also prints a directory listing. It then moves up one level and prints that out.

In case you are moving through many directories and need to get back to where the program is running from you can then use set dir homedir$

Hope that helps you with your problem


Rakansen
18
Years of Service
User Offline
Joined: 19th Jan 2008
Location:
Posted: 23rd Nov 2008 02:45
Thanks again. I tried this code:

and it started working. Unfortunately, I had to leave for work before I could continue. Now that I've returned, it stopped working. Now I'm really confused... I don't remember changing anything else... Who knew this could be such a big task?
Rakansen
18
Years of Service
User Offline
Joined: 19th Jan 2008
Location:
Posted: 23rd Nov 2008 02:48
OH, never mind. I figured out what changed- it wasn't the code, there was a text file inside the "Cards" folder. Looks like I'll need to create a new directory for storing card information.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Nov 2008 05:16
Also you can check for file extensions which could eliminate the need to start counting at 3 and account for any wierdness that changes the order of the strings. The ".jpg" assumes you only want jpegs. It could be .bmp or whatever.

perform checklist for files
for card = 1 to checklist quantity()
card$ = checklist string$(card)
if len(card$) > 4 and right$(card$,4)=lower$(".jpg")
load image card$,card
endif
next card

Enjoy your day.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Nov 2008 05:16
Also you can check for file extensions which could eliminate the need to start counting at 3 and account for any wierdness that changes the order of the strings. The ".jpg" assumes you only want jpegs. It could be .bmp or whatever.



Enjoy your day.
Rakansen
18
Years of Service
User Offline
Joined: 19th Jan 2008
Location:
Posted: 23rd Nov 2008 06:11
Thanks Latch, I went back to having trouble, but your code saved the day. Much appreciated!
steve paul thomas
17
Years of Service
User Offline
Joined: 4th Nov 2008
Location: United Kingdom
Posted: 28th Nov 2008 03:47
Yep, Latch's way is definetely better

Login to post a reply

Server time is: 2026-07-05 17:12:32
Your offset time is: 2026-07-05 17:12:32