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 Professional Discussion / Can someone help me make a Pokemon randomiser?

Author
Message
Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 3rd Nov 2014 19:05
I'd like to to make a random pokemon generator in DarkBASIC Pro, I don't know how to code though.

The regions and starter Pokemon available in the games are as follows:

Kanto: Bulbasaur, Charmander and Squirtle
Johto: Chikorita, Cyndaquil and Totodile
Hoenn: Treecko, Torchic and Mudkip
Sinnoh: Turtwig, Chimchar and Piplup
Unova: Snivy, Tepig and Oshawott
Kalos: Chespin, Fennekin and Froakie

What I'd like to happen is the program will say "Which region are you in?" at the top of the screen with the names of the regions below in a list just like I wrote above.

Make the colour of the active selection red so I can see which one is selected by the program before confirming it.

Then, when I use the up and down arrow keys on the keyboard, the program will scroll through the regions until I get to the one I want, I'll use Hoenn for this example.

Then, after I choose the region I want with the enter key, the program will then say "You are in: Hoenn."

Then below that, it will say "Your starter Pokemon is: Mudkip."

Of course, the region wont always be Hoenn and the Pokemon wont always be Mudkip. The program will randomly select the Pokemon out of the three choices available from the region that was chosen.

After the Pokemon has been selected for you, there should be another menu giving the options "Select again" which will randomly select a Pokemon a second time from the region you chose previously, and "Go back" which will take you back to the menu asking which region you are in.

How would I make a program that does this? I have no idea how to code except for the simple stuff like Print "Hello world" and Wait key. I've tried to make sense of the tutorials but everything goes completely over my head!

I'd like to run the program in an 800x600 window with Arial font (Set text font "Arial") and I noticed size 50 text (Set text size 50) seems to work well.

Could someone give me the code I'd need to make this program?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Nov 2014 23:42 Edited at: 3rd Nov 2014 23:57
Quote: "Could someone give me the code"


No, but we can help you understand and learn so you can program it yourself.

You should first learn about variables, learn about the different kinds of variables and what they can store, how to manipulate variables, and how you can use variables to control the flow of your program (if/endif statements).



[EDIT] Forgot to mention: Random numbers. You can generate them with the command rnd():


That's really all you need to write the program you described. I suggest reading through TDK's tutorials, they're a fantastic resource for beginners:
http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

The forums aren't here to do your work. They are here to help you solve specific problems. So, when posting here, you should:
1) Describe what you've already tried in detail. Post code, post illustrations, post whatever. Help us understand what you're having trouble with.
2) Don't ask for an entire program to be written for you, we aren't your slaves.

I like offending people. People who get offended should be offended. -- Linus Torvalds
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Nov 2014 01:37 Edited at: 5th Nov 2014 00:47
You had me at Hello World...




Mind you, there are dozens of ways one could organize and handle such data lists - mine is by no means textbook coding, I just slop around until it works.

Like chess, once you know the rules it's up to your logic and imagination to join forces and create what you want to see on the screen/board.

If you're serious about programming, my code includes an example of multi-dimensional arrays which are indispensable for keeping track of items with many attributes, like how many fish tanks you have, how many goldfish you have in each tank, the number of fins on each goldfish, and if a particular fin is torn or not!

You will also see GOSUB/RETURN and FOR/NEXT in action as well as READ/DATA and some basic input and print statements. You should be able to play with the code and make new lists, bettering your skills all the while.

There are many commands to learn, not to mention plugins that people swear by, half of which I've never used. Coding is an endless road of desires, rewards and failures... oh, the many, many failures.

Man, you can tell I live alone... I think I hear my goldfish calling.

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Nov 2014 15:44
Welcome Brally,

I wish all newbies explained their ideas as well as you!

Asking for code is frowned upon, but sharing code is greatly encouraged. The difference being that we can all learn from each other's code and there's nothing wrong with using a piece of code that someone has shared (as long as you give credit), but just asking for something to be written for you shows a lack of initiative and interest in learning.

If you don't understand what some code does then it is likely to cause you more problems than it's worth. You don't always have to understand every detail of how something works before you can use it, for example you might use a function that takes a number and outputs a number, as long as you know what to expect from the function you don't actually need a deep understanding of what's going on inside.

I can see a potential issue with Derek's code, and that's because the program halts at while scancode()<>0:ENDWHILE while it waits for key input. This means the program can't do anything until the user presses a key. It's usually far better to dynamically read input as it happens rather than pausing the entire program to wait for input. This is an example of how someone else's code might not be suitable for your needs even if they have written it specifically for you, because they aren't aware of everything the program will need to do.

Formerly OBese87.
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 4th Nov 2014 16:04 Edited at: 4th Nov 2014 16:06
Welcome aboard, Brally

Quote: "There are many commands to learn, not to mention plugins that people swear by, half of which I've never used. Coding is an endless road of desires, rewards and failures... oh, the many, many failures."

Yeah, but playing with logic is fun and very addictive

Documentations and us forum dwellers are your friends. Read and try to understand the commands, create processes, functions and ask questions. You'll get there eventually!

Edit
Typos...

Regards Sph!nx
Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 4th Nov 2014 17:02
I tried using the code Derek gave me and I get this

#100025 Declaration name "`" is not valid on line 28.

What is this?
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Nov 2014 21:17 Edited at: 4th Nov 2014 21:19
#100025 Declaration name "`" is not valid on line 28.

That sounds like it's complaining about Derek's commenting. Like here

selection=1 `starting menu position

Are you using DarkBASIC or DarkBASIC Pro? The text after the ` shouldn't be read by the compiler but this was a problem with DBC that you couldn't put comments on the same line after commands, unless you break the line with a colon, like this

selection=1 :`starting menu position

Formerly OBese87.
Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 4th Nov 2014 22:39 Edited at: 5th Nov 2014 14:24
Quote: "Are you using DarkBASIC or DarkBASIC Pro?"


I'm using DarkBASIC Pro.

I fixed the problem with the first error, now I've got another one!

#100016 NEXT only takes one parameter at line 35.

Because I don't have a clue how to code, I'm just going to post any and all errors I get on here so I'll eventually have a fully working program.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 5th Nov 2014 00:51 Edited at: 5th Nov 2014 00:56
Quote: "while scancode()<>0:ENDWHILE while it waits for key input. This means the program can't do anything until the user presses a key"


The opposite actually - in this case it's saying don't continue if a key is already being pressed. The user can only get there by pressing a key so the only possible pause is user-sustained, as intended. =)

So, I've updated the code with REM instead of `
Hopefully that'll work!

And yes, it's better to ask for 'pointers' instead of code, but one must see some working code to get the best insights, and there's certainly plenty of code passed around among veterans, so I say skip the hazing and shaming and show the kid some dang code! LoL

wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 5th Nov 2014 02:41
Quote: "And yes, it's better to ask for 'pointers' instead of code, but one must see some working code to get the best insights, and there's certainly plenty of code passed around among veterans, so I say skip the hazing and shaming and show the kid some dang code! "

Admit it, you were bored and just felt like coding.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 5th Nov 2014 03:51
Quote: "Admit it, you were bored and just felt like coding."


Come on, when there are Pokemon waiting to be randomly chosen?!
Who could just sit there with their thumb in their thimble?

Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 5th Nov 2014 18:59
Quote: "#100016 NEXT only takes one parameter at line 35."


What is this? I don't even know what a parameter is!

Line 35 is For Namesake=0 to 3
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 6th Nov 2014 00:01
A parameter is information that you need to provide to a command. In this case, a 'for' statement creates a variable 'namesake' and assigns it the first value in a range of values 0-3. It will process the code below it until it hits a 'next' command then it will advance to the next value in the range and repeat until the range is fully processed or you tell it to stop. The error is likely because the 'next' command here does not tell the program 'next what?' It is missing the parameter of what variable you want to advance through as in 'next namesake'

Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 6th Nov 2014 00:22
Quote: "The error is likely because the 'next' command here does not tell the program 'next what?' It is missing the parameter of what variable you want to advance through as in 'next namesake'"


Quote: "
for ThisRegion=1 to Regions
for Namesake=0 to 3
"


How would I go about fixing this part of the code then?
I don't know how to write code at all.
I'm going to keep asking how to fix the code one line at a time if necessary until the code works the way I want it to.

I really don't want to make people feel like I'm doing it this way just to be annoying or anything, I honestly can't make sense of the instructions explaining how to code.
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 6th Nov 2014 18:57
those lines are fine the issue is at the bottom of the loop where it says

next
next

should probably be

next namesake
next thisregion

Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 6th Nov 2014 19:36
This should probably be the last error I'll experience as I'm near the end of the code now.

#100016 NEXT takes only one parameter at line 56.

The line that shows in red is

for p=1 to Regions

There is a NEXT a bit further down though, I'm obviously missing something there like the other NEXT line before.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 7th Nov 2014 01:25 Edited at: 7th Nov 2014 01:43
FOR/NEXT is a loop... for every FOR there should be a NEXT.

The first set you see in my code is called a 'nested loop' because one is inside the other, useful for taking care of more than one thing at a time, or things which relate to or affect each other.

Things happening inside a FOR/NEXT loop get repeated the number of times specified by FOR x=n to n2, like FOR MakeDot=1 to 100 as an example. (*MakeDot is not a command, but an imaginary variable container.)

A very basic example of FOR/NEXT could be:



Keep the questions coming and this will eventually pan out and hopefully you'll have learned a bit too!

Brally
11
Years of Service
User Offline
Joined: 3rd Nov 2014
Location:
Posted: 7th Nov 2014 13:24
I managed to fix the problem I had with the last FOR/NEXT loop.

As it turns out, all I was missing was a p after the NEXT. My dad was the one who pointed it out.

I had a problem compiling it at first, but that was only because I've been using a version of DarkBASIC Pro that I downloaded from a bit torrent site with all of the plugin files missing.

I compiled it with the demo version available on this site and it works perfectly.

Thanks for all your help.

If you play the Pokemon games,you can use the program yourself if you like.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Nov 2014 16:05
Quote: "I compiled it with the demo version available on this site and it works perfectly."


DarkBASIC Professional is now free, download it here.

Quote: "I've been using a version of DarkBASIC Pro that I downloaded from a bit torrent site"

Better do a full virus scan then
Oh, and leave the torrents alone, it will only end in tears.

Hopefully you've had a taste of programming and want to do more. As the comment mentioned, Start HERE.

Quidquid latine dictum sit, altum sonatur
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Nov 2014 21:26
Quote: "As it turns out, all I was missing was a p after the NEXT. My dad was the one who pointed it out."


I thought that wasn't necessary now. Perhaps you are using an old version? The following works fine for me:



Quote: "I've been using a version of DarkBASIC Pro that I downloaded from a bit torrent site"


Why? When you can download the real thing for free from here?

Glad you got it working all the same.

Welcome to the land (minefield?) of coding.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-17 12:28:39
Your offset time is: 2026-07-17 12:28:39