プレイ日記
ENIGMA BrutusBatutus
I'm used to Java. I just started trying to figure out BASIC and I got many questions.
0そうだね
プレイ済み
返信[1]
親投稿
Oscar PwnageBlock
1. Yes they do! You can declare one using DIM. Like this: DIM ARR[10] 2. Yes they are! Just make sure not to forget the ENDIF at the end of each multi-line if statement. 3. Sadly, that's not possible with the 3DS version of SmileBASIC. However, a version for Wii U will release that will have USB keyboard support. 4. The Guide, of course!
1そうだね
プレイ済み
返信[2]
親投稿
Oscar PwnageBlock
5. If statements in SB are pretty much the same as in any other programming language. To make multi-line if statements you need to follow the following syntax... IF (condition) THEN 'DO SOMETHING ELSE 'DO SOMETHING ELSE ENDIF It's also worth noting that comments in SB are preceded by a ', and not // or /*. 6. The modulo operator does exist! It follows the syntax of N1 MOD N2.
0そうだね
プレイ済み
返信[3]
親投稿
Oscar PwnageBlock
7. (10/3!=2)==TRUE. SB works with double values by default. 8. No, but a tin can. 9. You can specify the number type, although it is a bit weird. You can write # at the end of a variable to declare it a double, a % to declare it a decimal, or a $ to declare it a string. 10. ??? Something to do with the Flash? ???
0そうだね
プレイ済み
返信[4]
親投稿
Oscar PwnageBlock
11. It's matrices, and they do exist! You can declare a multi-dimensional array with this syntax... DIM MAT[10,4] Up to four dimensions can be specified.
0そうだね
プレイ済み
返信[5]
親投稿
ENIGMA BrutusBatutus
I figured out the comment thing. You said double and decimal. Are they not the same thing? Also, I'm used to 10/3!=false because the numbers would be ints, not doubles. My question then is are ints in BASIC? Also, Matrices! I just didn't know how it was spelled. And yes The Flashpoint Paradox is a big Flash thing. If you watch the show, you know why I mention it.
0そうだね
プレイ済み
返信[6]
親投稿
ENIGMA BrutusBatutus
I just realized I said 10/3!=false. I meant 10/3!=2 is false. 10/3==2 is true.
0そうだね
プレイ済み
返信[7]
親投稿
ENIGMA BrutusBatutus
Also, I have no idea what DIM is. And does there really have to be a ? mark when I want user input? I couldn't say "Enter a number: ", I have to ask "What is the number?"?
0そうだね
プレイ済み
返信[8]
親投稿
Alex MrCashews
An addendum to the number types: variable typing is determined when you declare them with VAR. You use a suffix character at the end of the name. VAR A$ would be a string, VAR A% would be int and VAR A# is double. No suffix defaults to double, unless you set OPTION DEFINT in which case it defaults to int (I recommend just always using suffixes)
1そうだね
プレイ済み
返信[9]
親投稿
Alex MrCashews
Numbers are, by default, treated as real-type. There is an integer division operator DIV which treats its terms and result as integers. ex. 10 DIV 3 is 2. SB also has implicit conversion from int to real and vice-versa so there's no headaches about that. 10.8 DIV 3 is 10 DIV 3 in its eyes.
1そうだね
プレイ済み
返信[10]
親投稿
ENIGMA BrutusBatutus
Thanks, both of you. I still have questions, like how do I print an array in a print statement, but I'll probably get these questions answered eventually. I actually have no idea what to do with SB, though. I thought I'd try recreating the text based battleship I made somewhat recently in java, in my computer science class, but with my limited knowledge of BASIV, I doon't think I can even start
0そうだね
プレイ済み
返信[11]
親投稿
ENIGMA BrutusBatutus
Any ideas on what I should try and set out to would be appreciated. Also, excuse the typos. Its late and I don't know why I'm not sleeping.
0そうだね
プレイ済み
返信[12]
親投稿
Oscar PwnageBlock
To make an input without the question mark use a comma instead of a semicolon. To print an array, simply make a loop that goes through the array and print each element one by one. You should start using SB with the console. You can clear the console with the CLS command, change the cursor position with LOCATE, change foreground/background color of text with COLOR and some constants, etc.
0そうだね
プレイ済み
返信[13]
親投稿
Oscar PwnageBlock
If you need help with anything, just ask!
0そうだね
プレイ済み
返信[14]
親投稿
ENIGMA BrutusBatutus
Alright so I have a few more questions for now. I started making the battleship game again but I realized I don't know if arrays have to be number arrays or if I can, how to create a char array (I'm assuming I'd have to use a string array instead, if possible). I could get away with not using a char array just fine, but, hey.
0そうだね
プレイ済み
返信[15]
親投稿
ENIGMA BrutusBatutus
Also, when I create an array, in Java, I can set every element to what I want it to be: arr={2,3,3,4,5} or some thing like that. I don't know if its possible in BASIC, though. for now, I just set them seperately arr[0]=2 arr[1]=3 arr[2]=3 arr[3]=4 arr[4]=5 I also need to better understand booleans, and I don't know about while loops or if do while loops exist
0そうだね
プレイ済み
返信[16]
親投稿
ENIGMA BrutusBatutus
I may not need a do while loop, but when I made my battleship game in Java, I could only get it working properly with a do while loop. Had to do with making sure the ships don't overlap each other
0そうだね
プレイ済み
返信[17]
親投稿
Oscar PwnageBlock
You can create a char array by typing the array identifier as a string. Like this... DIM ARR$[10] Assigning values to an array in SB must be done element by element. A bit inconvenient, but not too much. The Boolean values TRUE and FALSE and constants #TRUE and #FALSE in SmileBASIC are actually just the numbers 1 and 0, although using their Boolean names is a good programming practice.
0そうだね
プレイ済み
返信[18]
親投稿
Oscar PwnageBlock
There are 3 (technically 4) kinds of loops in SmileBASIC: - WHILE...WEND Loops: These are your standard Do-While loops. They take the following syntax... WHILE <Expression> 'DO STUFF WHILE EXPRESSION IS TRUE WEND
0そうだね
プレイ済み
返信[19]
親投稿
Oscar PwnageBlock
-REPEAT...UNTIL Loops: These are also present in Java, and follow almost the same syntax. Unlike WHILE loops, these execute at least once and stop when the expression is true. The syntax is... REPEAT 'DO STUFF UNTIL <Expression>
0そうだね
プレイ済み
返信[20]
親投稿
Oscar PwnageBlock
-FOR...TO...STEP...NEXT Loops: These are your standard For loops. Their syntax differs a bit from Java, but it follows the same idea. I'll translate an example from Java for this one... Java: for(int i=0; i<10; i+=2){ //Do Stuff } SmileBASIC: FOR I=0 TO 9 STEP 2 'DO STUFF NEXT
0そうだね
プレイ済み
返信[21]
親投稿
Oscar PwnageBlock
These are technically not proper loops, but it appears most people use them as such. -@LABELS and GOTO: You can define a label by writing anything preceded by a @. You can then use GOTO @LABEL to skip the program to where the label is... @LOOP 'DO STUFF GOTO @LOOP
1そうだね
プレイ済み
返信[22]
親投稿
ENIGMA BrutusBatutus
I was able to get away with using the while loop. I did not know about the REPEAT UNTIL, buy it sounded a lot like a do while loop, executing at least once. I was also able to get away with not using a char array.
0そうだね
プレイ済み
返信[23]
親投稿
ENIGMA BrutusBatutus
I ran into another problem, though. In Java, there are methods. Very handy. Very dandy. But, I cannot figure out how to replace them in BASIC. I tried using labels and GOTO, but that executew ALL lines after the label. I tried labels, GOSUB, and RETURN, but only recieved RETURN without GOSUB errors and whatever. I need to know how to replace methods and how exactly labels and GOTO/GOSUB work.
0そうだね
プレイ済み
返信[24]
親投稿
Alex MrCashews
Look into DEF. Here's examples: DEF TEST NAME$ PRINT "HELLO, "+NAME$ END TEST "Jimmy" DEF SQUARED(NUM#) RETURN NUM#*NUM# END PRINT SQUARED(2) Something weird to mention: DEFs are completely untyped, they don't even type check their arguments! You can also make DEFs that don't take arguments, so they make gosub and goto completely obsolete.
1そうだね
プレイ済み
返信[25]
親投稿
Oscar PwnageBlock
Something really important that I forgot to mention... SmileBASIC, unlike Java, is NOT an object-oriented programming language. It is a procedural, structured programming language. This means that there is no such thing as a class, an object, or even a struct. There are workarounds, but you should try to get used to not having them.
0そうだね
プレイ済み
返信[26]
親投稿
ENIGMA BrutusBatutus
Thanks again. I got the game basically finished, except for one thing. I replaced the numbers to the top with letters, and the game translates the letter into a X-coordinate, but I realized that Battleship might actually have the letters to the side, for the Y-coordinate. This makes things a bit more complicated. Is there a way, like in Java, to change A to B easily, like A+1 would normally?
0そうだね
プレイ済み
返信[27]
親投稿
ENIGMA BrutusBatutus
If not, or if you don't know what I'm asking, how would I change the numbers to the side to letters? do I have to use a bunch of if statements to convert it or is there a better way?
0そうだね
プレイ済み
返信[28]
親投稿
Oscar PwnageBlock
There is a way! You can use the CHR$ function to get an ASCII/UTF character through its numerical ID. You can get the numerical ID of any character with the ASC function. The value for A is 65, and the rest of the letters all have consecutive values (E.g.: B is 66, C is 67, etc.), which means you can do something like this... FOR I=0 TO 9 ? CHR$(65+I) NEXT
1そうだね
プレイ済み
返信[29]
親投稿
ENIGMA BrutusBatutus
Alright! I have now completely finished the Battleship game! I may try to add more to in the future, but the game is fully functional. Thanks for your help
0そうだね
プレイ済み
返信[30]
親投稿
ENIGMA BrutusBatutus
I made a heads or tails game for no real reason. I had just decided it was finished, and that I wanted to check out my Battleship game agaim. I load it up, and I'm told there is a syntax error. "What?" I look at the code I thought I loaded Battleship? This isn't Battleship! And there wasn't a syntax error two seconds ago! Wait, where's the rest of the code? Waaaaiitt...maybe this IS Battleship!"
0そうだね
プレイ済み
返信[31]
親投稿
ENIGMA BrutusBatutus
"¡¡¡¡¡¡NOOOOOOOOOOO!!!!!! ¡¡¡¡¡¡MÎ TORTAAAAAAAAAAAA!!!!!!
0そうだね
プレイ済み
返信[32]
親投稿
Oscar PwnageBlock
If you mean to say that you've overwritten your project, SmileBASIC keeps a backup for your most recently worked on file. I believe it's called BACKUP.PRG or something similar. Try to look for it in your project folder.
0そうだね
プレイ済み
返信[33]
親投稿
Alex MrCashews
You forgot to save it didn't you? That sucks. Here's a protip: hit SHIFT/F2 with a slot editor open to pull up a save dialog. Never use DIRECT to save again! F1 becomes LOAD as well. Simply having more than one slot is a godsend as well in editing. Also as a person on the internet I'm required to acknowledge my recognition of that reference. ;-)
0そうだね
プレイ済み
返信[34]
親投稿
ENIGMA BrutusBatutus
I definitely saved the Battleship program as I had worked on it for days and then decided to work on the heads/tails thing. I must have somehow at somepoint overwritten it. I have the Battleship program that is now an unfinished heads/taild program and the coin toss program that is the finished one. I had noticed the backup thing, but had no idea what it was.
0そうだね
プレイ済み
返信[35]
親投稿
ENIGMA BrutusBatutus
I'll check it out and hope its not a backup of the wrong program. Also, I was done with Battleship when I started the coin toss thing so I didn't think I would need the other slots. I also noticed shift changed the save into a button or whatever it does, but it didn't say the same thing it usually does so I didn't want to take any risks. Also, I'm glad you got that reference.
0そうだね
プレイ済み
返信[36]
親投稿
ENIGMA BrutusBatutus
I realize now that those two comments were from two different people which makes more sense. Anyway, it is as I feared. The backup is of the coin toss program. I think I'm just going to never touch SB again. I'll probably burn and smash my DS. If I'll ever use SB again, it'll be when the next DS comes out and has its own version of it.
0そうだね
プレイ済み
返信[37]
親投稿
ENIGMA BrutusBatutus
And I'm never making another Battleship game. If I do, when that next SB comes out, it'll be 200x better and have graphics and multiplayer support and have a randomized theme. Like, it could be Batman themed, Spiderman themed, Battleship themed, or whatever randomly with a really catchy theme song playing in the background
0そうだね
プレイ済み
返信[38]
親投稿
ENIGMA BrutusBatutus
And it would be really fun. So fun and great it wins 200 GOTY awards for 200 years each. Anyway, I got a bit carried away with that. I'm just going to take an undoubtedly long break from programming, which was probably going to happen anyway since all the programming I did before was in CS class and I only recreated 1 program from that class. I'm too busy with Uncharted and Kombat anyway.
0そうだね
プレイ済み
返信[39]
親投稿
Oscar PwnageBlock
A bit of an overreaction, no? Good luck on your endeavors, anyways.
0そうだね
プレイ済み
返信[40]
親投稿
12Me21 12Me21
Yes,Yes,No,no IF condition THEN do something ELSEIF condtion THEN do something ELSE do something ENDIF MOD, ok..., no INT% FLOAT# float is default, make integer default using OPTION DEFINT ... I forget. Aren't those just 2D arrays? GOSUB is fine, but I don't use it much, just because my programs often don't have any subroutines.
0そうだね
プレイ済み