プレイ日記
Harley HarleyG1234
How do I get the paddle to move left and right?
1そうだね
プレイ済み
返信[1]
親投稿
Oscar PwnageBlock
While I'm sure there are various ways to implement it, I'll tell you how I'd do it. Use a variable to track the location of the paddle. Use the BUTTON command to get button input from the player. Use said input to change the variable of the paddle's location. Use the LOCATE command to print the paddle at a specified location, determined by the previously mentioned variable.
0そうだね
プレイ済み
返信[2]
親投稿
Oscar PwnageBlock
Of course, this should all be executed within a main loop so that the program runs continuously. At the end of the loop there should also be a WAIT command so that the program runs in a stable manner, and a CLS as to erase the console screen and prevent PRINT clutter.
0そうだね
プレイ済み
返信[3]
親投稿
Oscar PwnageBlock
You could get it to move left and right by using the value returned by BUTTON and using logic gates and constants to build conditionals for modifying the paddle's position value.
0そうだね
プレイ済み
返信[4]
親投稿
Oscar PwnageBlock
The code itself would look something like this... PP=0 'DECLARE PADDLE POSITION VARIABLE WHILE 1 'EXECUTE CODE CONTINUOUSLY 'CHANGE VARIABLE USING BUTTON INPUT IF BUTTON() AND #LEFT THEN INC PP IF BUTTON() AND #RIGHT THEN DEC PP 'LOCATE CURSOR FOR PRINT USING LOCATE AND THE VARIABLE LOCATE PP,3 PRINT "=------=" 'PRINT THE PADDLE 'PREPARE FOR NEXT FRAME WAIT 1 CLS WEND
1そうだね
プレイ済み