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 / Need Help with my first program...

Author
Message
Pyro gamesta
20
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 8th Oct 2005 21:26
i am trying to go to a new screen when i click on something for my first program.It will be a shotokan karate guide.i would appreciate the help

Here is my code so far....

When there is a will.....theres a way!!!
Pyro gamesta
20
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 9th Oct 2005 01:56
i am trying to go to a new screen when i click on something for my first program.It will be a shotokan karate guide.i would appreciate the help

Here is my code so far....

Rem My first Program
Rem Author : Troy Brown

Set display mode 640,480,32



rem Load a bitmap onto the screen
LOAD BITMAP \"tiger.bmp\"


set current bitmap 0
Text 310,240, \"Loading\"
Wait 1000
Text 310,240, \"Loading.\"
Wait 1000
Text 310,240, \"Loading..\"
Wait 1000
Text 310,240, \"Loading...\"
Wait 1000
Text 310,240, \"Loading....\"
Wait 1000



Cls
Goto Intro

Intro:

rem Load a bitmap onto the screen
LOAD BITMAP \"tiger2.bmp\"

Print \"Press Enter To Continue.\"

do
if returnkey()=1 then goto start
loop

start:
rem Load a bitmap onto the screen
LOAD BITMAP \"background.bmp\"

LOAD MUSIC \"Vampiredance.mp3\", 1
PLAY MUSIC 1

main_menu:
ink rgb(255,255,255),0
text 20,120,\"Who Created Shotokan?\"
text 20,160,\"Dojo Kun\"
text 20,200,\"Katas \"
text 20,240,\"Demos And Performances\"
text 20,280,\"Exit To Windows\"
repeat

Rem Who Created Shotokan
if (((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 110) and (mousey() <=130))) then ink rgb(255,255,0),0 : text 20,120,\"Who Created Shotokan?\"
if (((mousex() < 10) or (mousex() > 100)) or ((mousey() < 110) or (mousey() >130))) then ink rgb(red,511,0),0 : text 20,120,\"Who Created Shotokan?\"
if ((((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 110) and (mousey() <=130))) and (mouseclick()=1)) then end

Rem Dojo Kun
if (((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 150) and (mousey() <=170))) then ink rgb(255,255,0),0 : text 20,160,\"Dojo Kun\"
if (((mousex() < 10) or (mousex() > 100)) or ((mousey() < 150) or (mousey() >170))) then ink rgb(red,511,0),0 : text 20,160,\"Dojo Kun\"
if ((((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 150) and (mousey() <=170))) and (mouseclick()=1)) then end


do
if left click()=1 then Dojo Kun
loop

Dojo Kun:

Print \"New Screen\"






Rem Katas
if (((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 190) and (mousey() <=210))) then ink rgb(255,255,0),0 : text 20,200,\"Katas\"
if (((mousex() < 10) or (mousex() > 100)) or ((mousey() < 190) or (mousey() >210))) then ink rgb(red,511,05),0 : text 20,200,\"Katas\"
if ((((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 190) and (mousey() <=210))) and (mouseclick()=1)) then end

Rem Demos And Performances
if (((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 230) and (mousey() <=250))) then ink rgb(255,255,0),0 : text 20,240,\"Demos And Performances\"
if (((mousex() < 10) or (mousex() > 100)) or ((mousey() < 230) or (mousey() >250))) then ink rgb(red,511,0),0 : text 20,240,\"Demos And Performances\"
if ((((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 230) and (mousey() <=250))) and (mouseclick()=1)) then end

Rem Exit Windows
if (((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 270) and (mousey() <=290))) then ink rgb(255,255,0),0 : text 20,280,\"Exit To Windows\"
if (((mousex() < 10) or (mousex() > 100)) or ((mousey() < 270) or (mousey() >290))) then ink rgb(red,511,0),0 : text 20,280,\"Exit To Windows\"
if ((((mousex() >= 10) and (mousex() <= 100)) and ((mousey() >= 270) and (mousey() <=290))) and (mouseclick()=1)) then end
until false

When there is a will.....theres a way!!!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Oct 2005 04:17
What's with all the backslashes (\)? Is that what happens if you don't use the code button to paste code I wonder?...

Anyway, use the code button above right to insert code into your posts. The other method doesn't work while you are in newbie status. (It wears off after so many posts - not time).

Also, spend a while reading a few other posts on the board - especially the stickies (the one's with the green arrows on them at the top). If you read these, you'll get a better understanding of how the forums work - and save you getting angry replies too!

You are obviously new to programming in DB and don't know any better, but if you imagine the very worst way you can write a program, then make it twice as bad, then that's what you have done so far.

But, that's how most of use wrote programs the first time we tried it! Programming is something you will learn in time - with a little help, so don't let this worry you - so long as you decide to do something about it, it can soon be fixed.

I'm a purist and on most days, you'll be lucky to get any comment out of me at all in a post if I see Goto used in a code snippet. However, in this case, I think it's just that the layout of your program (or lack of it) makes it virtually impossible to avoid it. You just need pointing in the right direction.

Take a look at http://www.matedit.com and check out the tutorials for beginners on there - in particular, read the series 1 to 4 which contains info on how to structure your programs to avoid using Goto.

As I said, you have made a number of serious mistakes, like:

* more than one Do..Loop in a program
* using Goto to jump to the very next line (as if just using Goto wasn't bad enough lol)
* misuse of parenthesis on If lines (they aren't required)
* setting the current bitmap to the one you are already set to
* using lots of lines when you could just use a couple in a loop
* no end to the program
* no layout or structure

As I said, these are all perfectly normal for most beginners with no prior knowledge, so don't worry about it.

Read some tutorials and let them sink in, then throw the above program away and start again from scratch, based on a proper layout skeleton (you'll find one in the tutorials following the link above).

You'll find it so much easier and if you have any problems, post back here.

TDK_Man

Pyro gamesta
20
Years of Service
User Offline
Joined: 28th Apr 2005
Location:
Posted: 9th Oct 2005 08:59
lol sorry about that

When there is a will.....theres a way!!!

Login to post a reply

Server time is: 2025-05-22 13:33:54
Your offset time is: 2025-05-22 13:33:54