Archiverse Internet Archive
投稿のみ 投稿と返信
前のページ(最近)
13 4 5 6 7 8 9 10 11 12 13 14
次のページ(過去)
返信[1]
親投稿
Ed CPFace
This isn't a game -- it's more like a utility. It allows you to program your 3DS in BASIC. It takes some learning, but it's pretty powerful, and it has a lot of functions and utilities to make game design a little easier.
1そうだね
プレイ済み
返信[7]
親投稿
Ed CPFace
Pointers? I could have sworn there was a way to refer to a variable named in a string (for example, if A$="X", it could be used to refer to the variable X), but I've been through all of the instructions, and I can't find it. I might be thinking of a different language.
0そうだね
プレイ済み
返信[5]
親投稿
Ed CPFace
Since Z isn't listed in the definition for FUNC, it isn't masked off in any way. Therefore, when we use its value in line 7 and change it in line 9, we use it as a regular global variable, and it IS altered to 22 after the call to FUNC. This is all rather confusing, but hopefully it makes at least some sense and shows you how careful you have to be about the variables you use in your functions.
0そうだね
プレイ済み
返信[4]
親投稿
Ed CPFace
When Y is passed in as the value of B for a call to FUNC, it's passed by VALUE rather than REFERENCE. So when we change the local value B in line 8, the global value of Y is unaffected. After the call to FUNC, Y is still 3.
0そうだね
プレイ済み
返信[3]
親投稿
Ed CPFace
Our global variable B is masked off when we call FUNC, and so it's not affected by line 8, so after FUNC is called, it's still 10. Likewise, our global variable X is masked off when FUNC uses X for its return value, so it's still 7 after FUNC is called.
0そうだね
プレイ済み
返信[2]
親投稿
Ed CPFace
Notice that the function uses LOCAL values for all of the variables named in its definition, and GLOBAL values for all other variables. When the function evaluates A+B+Z, it uses the value 2 (passed in) for A, 3 (passed in as the value of Y) for B, and 20 (the global value) for Z. So when we return, A (our output variable in line 3) is 2+3+20=25.
0そうだね
プレイ済み
返信[1]
親投稿
Ed CPFace
Here's the output, A, B, X, Y, and Z.
0そうだね
プレイ済み
プレイ日記
Ed CPFace
Here's an illustration of how Smile BASIC handles scoping in its user-defined functions. What will FUNC do to our variables here?
4そうだね
プレイ済み
返信[1]
親投稿
Ed CPFace
I'm very interested to know how that's going to work!
0そうだね
プレイ済み
返信[22]
親投稿
Ed CPFace
Good luck! And if you want some examples, make sure you take a peek through the built-in programs.
1そうだね
プレイ済み
返信[19]
親投稿
Ed CPFace
... you're going to have a hard time rewriting it in the new system on your own. You might have to retranslate everything on a line by line basis, and the fact that all of the sprite and background graphics have been completely overhauled might make it useless anyway.
0そうだね
プレイ済み
返信[18]
親投稿
Ed CPFace
I'm starting to realize this program's been copied line for line from something written in PTC. The syntax for many, many of the commands have changed between the two versions. If this is your own program, you'd do well to spend some time flipping through the documentation at smilebasic.com (particularly the long instruction list) to see what's changed. If this is someone else's program...
0そうだね
プレイ済み
返信[3]
親投稿
Ed CPFace
1) Yeah, "END DEF" should be "END", I'm still thinking in another language. 2) It seems like that's just one of the quirks of this language.
0そうだね
プレイ済み
返信[1]
親投稿
Ed CPFace
Java is obviously a more advanced language than BASIC, with object-oriented features and all, but knowing the basic principles of programming puts you one step ahead of the game.
2そうだね
プレイ済み
返信[1]
親投稿
Ed CPFace
I'm guessing that you're trying to create user-defined routines without return values so that you can call them as commands, like: DEF ROUTINE(X,Y) ... END DEF ROUTINE(A,B) A function with arguments has to return a value. Read the doc for user-defined functions carefully, or post a screenshot of your code so we can see what's up.
0そうだね
プレイ済み
返信[15]
親投稿
Ed CPFace
@GTAerohog This is probably the one thing I dislike about this new version so far, as I liked using START for submenus and such. I'm guessing they figured that the START and SELECT were positioned close to the Home button on the standard 3DS and so were more like system keys than gameplay buttons.
0そうだね
プレイ済み
返信[12]
親投稿
Ed CPFace
A is 16. But in fact, there's a clever feature in this version: you can just write it as "#A" for clarity in your code and so you don't have to remember the number or look it up every time. So: IF BUTTON(2)==#A THEN ... Type BUTTON on any blank line and tap the ? button in the upper right of the keyboard for a list of all the button codes. Scroll through it with the circle pad while you edit.
2そうだね
プレイ済み
返信[7]
親投稿
Ed CPFace
Oh dear. Yeah, the START button has been taken over. Just like SELECT in PTC was a Break key, Start is now a break key as well. You'll have to figure out a different button to start with.
1そうだね
プレイ済み
返信[4]
親投稿
Ed CPFace
BUTTON()== will give you information for any button that happens to be held down at the time you call it. If you want the edge information of BTRIG -- that is, you only want to find out about a button at the moment it's pressed -- you use BUTTON(2)== instead of BTRIG()==.
1そうだね
プレイ済み
返信[1]
親投稿
Ed CPFace
I believe BTRIG() was replaced with BUTTON(2).
1そうだね
プレイ済み