- Dont be lazy
- I will add more later
hmm
One example
Here is one example:DIM MAP[100,100] FOR I = 0 TO 99 FOR J=0 TO 99 MAP[I,J] = RND(100) NEXT NEXTor you can do this:
DIM MAP[100,100] FOR CNT = 0 TO 99*99 I = FLOOR(CNT/99) J = CNT MOD 99 MAP[I,J]=RND(100) NEXTthe reason why it is faster is because it is slower to make nested loops
DON'T BE LAZY!
instead of this:FOR I = 0 TO 20 PRINT I NEXTdo this:
PRINT 1 PRINT 2 PRINT 3 PRINT 4 PRINT 5 PRINT 6 PRINT 7 PRINT 8 PRINT 9 PRINT 10 PRINT 11 PRINT 12 PRINT 13 PRINT 14 PRINT 15 PRINT 16 PRINT 17 PRINT 18 PRINT 19 PRINT 20
another method
if you have a main loop(a game, for example) and you want to update the map inside of it, do this:DIM MAP[W,H] VAR I,J WHILE 1 'code and all that INC I IF J == H-1 && I==W-1 THEN I = 0 : J = 0 IF I==W-1 THEN INC J:I=0 DOSOMETHING I,J'do something to the map, like set it as an empty tile for BG WENDthis method is going to update the map slowly, but it will not cause the main loop to have a low FPS
Use VSYNC conditionally
WHILE 1 M=MILLISEC IF B THEN CLS'AND OTHER STUFF B=!B 'DO SOMETHING IF MILLISEC-M>30.3030303 THEN VSYNC'30.3030303 milliseconds is 30 FPS. if fps is greater than 30,VSYNC to slow it down a bit WENDI will add more later