プレイ日記
~★Stuart★~ sonic2015boom
Hey guys! Im programming a game and i'm wondering if the code's too simple. If it is, give a tip on what to and where to do it. Thanks!
9そうだね
プレイ済み
返信[1]
親投稿
Nicole moesaku
I'm not sure if you're coming from Petit Computer, which limited IF statements to one line, but in SmileBASIC, you can have multiple lines in an IF, like so: IF B==8 THEN X=X+1 LOCATE X-1,Y PRINT " " ENDIF Also, rather than @LABEL ... GOTO @LABEL, I personally find it cleaner to use WHILE or REPEAT instead.
0そうだね
未プレイ
返信[2]
親投稿
Nicole moesaku
As for checking buttons, there are some things that can be improved. First, note that there are built-in constants for the buttons like #UP, #DOWN, #A, #B, #L, and so on. So, rather than B==8, you can write B==#RIGHT, which is a lot easier to understand.
0そうだね
未プレイ
返信[3]
親投稿
Nicole moesaku
The other issue is a bit more complex. Basically: B==#RIGHT is true when Right is the *only* button being pressed. B AND #RIGHT is true when Right is pressed, regardless of other buttons. It's hard to explain without getting into binary, but basically each button is a bit. AND matches the bits on one side with the bits on the other side, and creates a number with only the bits set on both.
0そうだね
未プレイ
返信[4]
親投稿
Nicole moesaku
So, when Right isn't pressed, B AND #RIGHT equals 0, because #RIGHT isn't set in B, but is set in #RIGHT. When Right is pressed, B AND #RIGHT equals #RIGHT, because #RIGHT is set on both sides. In other words, it'll be either 0 or #RIGHT. Any number that isn't 0 is considered true, so these come out as false or true.
0そうだね
未プレイ
返信[5]
親投稿
Nicole moesaku
This can be used for more complex button checks, too! For instance, B AND (#LEFT OR #RIGHT) is true when either Left or Right are pressed.
0そうだね
未プレイ
返信[6]
親投稿
~★Stuart★~ sonic2015boom
Okay. But... wow... thats a lot of comments...
0そうだね
プレイ済み
返信[7]
親投稿
~★Stuart★~ sonic2015boom
Ok. So I took your advice, but when I load, I can't move! Could you help point out mistakes?
0そうだね
プレイ済み
返信[8]
親投稿
Nicole moesaku
It's because you've moved some stuff out of your loop. The line where you update B and the line where you print the player should be inside your loop, like in your first screenshot, or else they'll only be run once. Also, note that ENDIF is only necessary if you split your IF into separate lines. This doesn't need ENDIF: IF condition THEN code This does: IF condition THEN code ENDIF
0そうだね
未プレイ
返信[9]
親投稿
~★Stuart★~ sonic2015boom
OK. Thanks!
0そうだね
プレイ済み
返信[10]
親投稿
~★Stuart★~ sonic2015boom
IDEK what you meant, but was It get rid of endif completly? Or get rid of it in certain areas?
0そうだね
プレイ済み
返信[11]
親投稿
Aaron Krondelo
You should only set VSYNC to 1, in rare cases maybe 2.
0そうだね
未プレイ
返信[12]
親投稿
Nicole moesaku
Yes, ENDIF isn't needed with your code. It's only needed if you have code like this: Line 1> IF B==#RIGHT THEN Line 2> PX=PX+1 Line 3> LOCATE PX-1,PY Line 4> PRINT " " Line 5> ENDIF because otherwise it wouldn't know where the IF ends. Your code is like: Line 1> IF B==#RIGHT THEN PX=PX+1:LOCATE PX-1,PY:PRINT " " so it doesn't need ENDIF because that form of IF ends at the end of the line.
0そうだね
未プレイ
返信[13]
親投稿
Nicole moesaku
That is a good point about VSYNC. At the moment, it looks like you have VSYNC 5 to limit the speed of the player. That's fine, but it limits your whole game to 12 frames per second, since 60 divided by 5 is 12. For a simple game this is probably okay, but if you want to limit this to just the player, you could use a variable that counts down each frame before it allows the player to move.
0そうだね
未プレイ
返信[14]
親投稿
~★Stuart★~ sonic2015boom
I said screw it so im just gonna stop with this game completely. Seriously, I-I just... it was hard work! ▼▲▼
0そうだね
プレイ済み
返信[15]
親投稿
HTV04 HTV04Rules
Don't give up! You're very close to making a complete program! Many developers face hardships when making games. Some have even lost the entire source code to their game and had to rewrite it from scratch. And yet they've made awesome games anyway. Just keep programming your game. You'll finish it eventually!
0そうだね
未プレイ
返信[16]
親投稿
~★Stuart★~ sonic2015boom
Well now, i'm planning a golf game. Yeah. Very, boring, sport.
0そうだね
プレイ済み
返信[17]
親投稿
Aaron Krondelo
That's going to be hard. I recommend starting with something simple. Otherwise you might give up again.
0そうだね
未プレイ
返信[18]
親投稿
~★Stuart★~ sonic2015boom
Well, i'm planning for a power gauge, and a multiplayer feature!
0そうだね
プレイ済み