idflyfish Posted July 8, 2011 Share Posted July 8, 2011 Hello, I have been writing little programs to become more familiar with extended basic. The following program draws a checker board on the screen and then uses a sprite to jump from each black square in a loop. I needed to determine if a column was an even or an odd column but I couldn't find a modulus function or operator so a used the code in lines 121 and 125 as a work around. Is there a better way to determine if a number is odd or even using extended basic? 100 CALL CLEAR 120 FOR R=1 TO 20 121 X=R/2 125 IF INT(X) = X THEN S=2 ELSE S=1 130 FOR C=S TO 24 STEP 2 135 CALL CHAR(91,"FFFFFFFFFFFFFFFF") 140 CALL HCHAR(R,C,91) 150 NEXT C 160 NEXT R 220 FOR R=1 TO 20 221 X=R/2 225 IF INT(X) = X THEN S=2 ELSE S=1 230 FOR C=S TO 24 STEP 2 235 CALL CHAR(91,"FFFFFFFFFFFFFFFF") 240 CALL SPRITE(#1,91,4,R*8-7,C*8-7) 250 NEXT C 260 NEXT R 270 GOTO 220 Also, feel free to leave any comments or pointers on how I could better implement this program in extended basic. Thanks! Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.