LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

New to Smilebasic, but wondering how to make a counting program

Root / General / [.]

legofordmnCreated:
New to Smilebasic, but wondering how to make a counting program where it would print each individual number, like if it would count for nearly forever.

Never mind, figured out how to do that. However, is there a way a variable could be a specific line of code? If so, could you give me an example to use?

What have you tried?

However, is there a way a variable could be a specific line of code? If so, could you give me an example to use?
I’m not too sure what you mean by that. What are you doing right now for variables?

Its seems you are realy new. So welcome to Smilebasic :-) I thoght, that your problem is that each variable is printing in a new line. You have to "refresh" the Display. Try to use command CLS to fix this. (Don't forget VSYNC for maximum Speed or setting Frame-rate)

Ok, thank you guys for responding so quickly. However, I have a new problem. I am trying to make Minecraft for the 3DS a reality, and I made a super flat world with a purple block sitting on the grass what I want to do is make an effect where if you press up on the d-pad, the player will walk forward making the block get bigger and bigger as it moves toward it. Can you guys give me some tips on how to do something similar to this?

w-wait, we're going from a counting program to minecraft? aren't there a few steps missing in there? If you really want to do 3D, I would suggest learning one of the engines that already exist: SIM.3D, P3D, etc. rather than trying to write your own.

✎ 989Yttria Head Admin Are those programs ported to Smilebasic?

I'd recommend gradually gaining toward the goal of a 3-D Minecraft clone. Moving from a counting program to 3D rendering and movement would be like learning how to throw a ball, and then playing in the NFL the next day; it's just not.. practical. It'd be much better if you had some practice first. Some things you might want to try to get some hands-on experience with SB: Learn how to use GCIRCLE and all of the other graphics commands so you can draw shapes to the screen, then figure out how to add color to them, etc. Figure out how to use the D-pad for moving a sprite across the screen, and find ways to add sound effects (BEEP command) and music (BGMPLAY command) into it. There are many tutorials on here that explain just about everything related to SB, so if you have trouble figuring out a specific command, try searching for a thread with the same question before asking on another thread.



I have a hard time seeing anyone completely new to programming being able to understand any of those... EH http://smilebasicsource.com/page?pid=50 this is the game Spooky Maze, but it also has the Raycaster library included.

Ok, sorry if I am annoying you guys with problems, but I just want to figure out coding. Anywho, how do you save your programs to Smilebasic? As in, what statement do I use to save my programs?

The simplest way to save a program is holding down L or R in edit mode, and tapping on the save button at the top of the bottom screen (it’ll ask you to give a name for the program if it hasn’t been saved already).

Don't forget Raycaster
Based off of what has been said, raycasting isn't good for minecraft ports. But, it does help build up to 3d stuff.

Ok, how do you make a text scroll intro, if you know what I mean, because if I type in, PRINT, it will just print out the entire text at once, and I don't want it to do that, so do see what I am trying to get at here?

Is this the sort of thing you are after? Remember you need to animate things, and that requires a game loop. You could put in a pause between print statements more easily but that doesn't let you animate or do other things in-between print statements. Please give this a read and let me know if you have any questions. Since you went from number counting to minecraft with nothing in between I assume you should have a lot of questions.
OPTION STRICT 'MAKE ME DECLARE VARIABLES

'VARIABLE DECLARATIONS
VAR CHAR_W = 8, CHAR_H = 8 'FAKE CONSTANTS
VAR SCREEN_W = 400, SCREEN_H = 240
VAR END_FLAG$ = "@"

VAR I, X, Y, DX 'REGULAR VARIABLES
VAR LINE$
VAR MESSAGE$[0]
VAR QUIT_FLAG


'READ THE TEXT TO SCROLL, AND
'SAVE IT IN A HANDY ARRAY, ONE
'ENTRY PER LINE
RESTORE @SCROLL_TEXT
READ LINE$
WHILE LINE$ != END_FLAG$
 PUSH MESSAGE$, LINE$
 READ LINE$
WEND

'DRAW A NICE DARK BACKGROUND
'JUST TO SHOW OFF DOING OTHER
'THINGS WHILE THE TEXT SCROLLS
SETUP_BG

'EXIT EARLY IF SET TO TRUE
QUIT_FLAG = FALSE

'SETUP VARIABLES
X = 0
DX = 1
Y = SCREEN_H - 1 'START AT BOTTOM OF SCREEN
GPRIO -255       'PUT DRAWING IN FRONT

'GAME LOOP
'EXIT WHEN WE FINISH SCROLLING OR THE 
'USER HITS THE EXIT BUTTON
WHILE (Y >= -1 * (LEN(MESSAGE$) * CHAR_H * 2)) AND QUIT_FLAG == FALSE
 'CLEAR THE SCREEN TO TRANSPARENT
 GFILL 0, 0, SCREEN_W - 1, SCREEN_H - 1, 0
 
 'WRITE OUT THE TEXT BASED ON OUR SCROLL 
 'POSITION
 FOR I = 0 TO LEN(MESSAGE$) - 1
  CENTER_PRINT MESSAGE$[I], Y + (I * CHAR_H * 2)
 NEXT I
 
 'SET UP THE NEXT ANIMATION FRAME
 Y = Y - 1
 X = (X + DX)
 IF X < 0 THEN 
  X = 0
  DX = 1
 ELSEIF X >= SCREEN_W THEN
  X = SCREEN_W - 1
  DX = -1
 ENDIF
 
 'MOVE THE BACKGROUND LAYER TO PROVE
 'WE CAN DO MULTIPLE THINGS AND AREN'T
 'BLOCKING
 BGOFS 0, X, 0
 
 'WAIT FOR THE SCREEN TO REFESH
 VSYNC
 
 'SEE IF WE NEED TO EXIT EARLY
 IF (BUTTON(3) AND #B) != 0 THEN
  QUIT_FLAG = TRUE
 ENDIF
WEND

END

'DRAW A LINE OF TEXT ON THE SCREEN CENTERED 
'AND AT THE DESIRED Y-COORDINATE
DEF CENTER_PRINT VALUE$, Y
 VAR X
 
 'EXIT EARLY IF OFFSCREEN
 IF Y >= SCREEN_H OR (Y + CHAR_H) < 0 THEN
  RETURN
 ENDIF
 
 'FLOOR ROUNDS DOWN
 X = FLOOR((SCREEN_W - (LEN(VALUE$) * CHAR_W)) / 2)
 GPUTCHR X, Y, VALUE$, #WHITE
END

'SETUP OUR BACKGROUND WE WILL BE SCROLLING
DEF SETUP_BG
 VAR TILE_SIZE = 16, TILE = 571 'BLUE BLOCK
 VAR COLS = (SCREEN_W / TILE_SIZE) * 2 
 VAR ROWS = (SCREEN_H / TILE_SIZE)
 ACLS
 BGSCREEN 0, COLS, ROWS 
 BGFILL 0, 0, 0, COLS, ROWS, TILE
END

'THE TEXT TO SCROLL
'STOP READING WHEN WE GET "@"
@SCROLL_TEXT
DATA "It was the best of times,"
DATA "it was the worst of times,"
DATA "it was the age of wisdom"
DATA "it was the age of foolishness,"
DATA "it was the epoch of belief,"
DATA "it was the epoch of incredulity,"
DATA "it was the season of Light,"
DATA "it was the season of Darkness,"
DATA "it was the spring of hope,"
DATA "it was the winter of despair,"
DATA "we had everything before us,"
DATA "we had nothing before us,"
DATA "we were all going direct to Heaven,"
DATA "we were all going direct the other way"
DATA "-- in short, the period was so far"
DATA "like the present period, that some of"
DATA "its noisiest authorities insisted on"
DATA "its being received,"
DATA "for good or evil,"
DATA "in the superlative degree"
DATA "of comparison only"
DATA "@"

Obscure fact: there's actually a command designed for this, SCROLL.
ACLS
?"HI"
?"AYY"
?"LMAO"
?"OATMEAL"
@A
WAIT 3
SCROLL -1,0
GOTO @A
It isn't very powerful, but for beginners it's simple enough.

How have I never heard of that command after all this time I’ve used SB

Is there a color eyedropper technique or something similar when you are designing textures, maps, etc.