The good habit tip was given. "Try not to rely on GOTO's." One step at a time, buddy. One step at a time.Looks to me like an argument over advanced coding practices in a beginner's help thread.At the beginning is the best place to develop good habits, and avoid bad ones. After the beginning, it gets quite a bit harder to do that.
New to Smilebasic need challenge suggestions
towerbooks3192Created:
While i have your attention. I am using TOUCH to get the position of the touch screen. I then print the position on the screen. For some reason, the Y value freaks out and displays the wrong number. Especially when I'm touching nearer the top of the screen. 7R7QN3QJ Do you know what's happening here?It looks like the text you printed isn't getting cleared, so if Y is, say, 123, and then changes to 99, the 3 will stay on screen and it'll look like 993.
I feel like an idiot now haha thank youWhile i have your attention. I am using TOUCH to get the position of the touch screen. I then print the position on the screen. For some reason, the Y value freaks out and displays the wrong number. Especially when I'm touching nearer the top of the screen. 7R7QN3QJ Do you know what's happening here?It looks like the text you printed isn't getting cleared, so if Y is, say, 123, and then changes to 99, the 3 will stay on screen and it'll look like 993.
The good habit tip was given. "Try not to rely on GOTO's." One step at a time, buddy. One step at a time.Sorry, I was following JustGreat's lead in assuming that even a beginner can handle more than one ('the') tip. Especially, one asking to be challenged.
Ok, all I asked for was some simple challenge suggestions like a number generator and a list. Now that escalated quickly. I will mess around with the game some more and keep those coding tips in mind for when I will get to the more advanced level.
Ideas:
- Print "Hello World"
- Create a function that returns temperature in celsius given farenheit and another that goes from celsius to farenheit.
- Ask the user's name and age. Tell them they are old, a baby, etc. depending on age ranges.
- Random number guessing game. Computer picks a random number. User enters in guesses. Computer say if you need to guess higher or lower. User wins if they guess the number.
- Hangman. User guesses letters (a through z) of a secret word (from a list of secret words). With each miss draw part of the man. Guess the word to win, run out of body parts to lose.
- Tic Tac Toe or Naughts and Crosses. Bonus points if you can play against the computer
- Mad Libs ask the user for a set of nouns, verbs, etc. When complete print out the resulting silly story. Bonus points if you can load questions and story template from file.
- FizzBuzz. Create a program that prints numbers 1 to 100. However, if the number is a multiple of 3 print Fizz. If it is a multiple of 5 print Buzz, and if it is a multiple of both 3 and 5 print FizzBuzz.
- Word Scramble. Pick a word from a list of known words and randomly mix up the letters. User enters guesses of the original words and wins on a match.
- Slot machine/One armed bandit. Keep track of winnings and losses.
Ideas:This is a pretty solid starting goal. Thanks for this. I checked the site but kinda scared to open it since I am unfamiliar with it. I came here directly to ask for challenges since I know it will be Smilebasic specific but I will try and see that site again once i feel comfortable with this app. Keep the text challenges coming then I might move to more graphical ones.You should be able to do those with just text. Bonus points for graphics. Let me know if you want more. That was a no on the exercism thing right, or did it just get lost in the deluge?
- Print "Hello World"
- Create a function that returns temperature in celsius given farenheit and another that goes from celsius to farenheit.
- Ask the user's name and age. Tell them they are old, a baby, etc. depending on age ranges.
- Random number guessing game. Computer picks a random number. User enters in guesses. Computer say if you need to guess higher or lower. User wins if they guess the number.
- Hangman. User guesses letters (a through z) of a secret word (from a list of secret words). With each miss draw part of the man. Guess the word to win, run out of body parts to lose.
- Tic Tac Toe or Naughts and Crosses. Bonus points if you can play against the computer
- Mad Libs ask the user for a set of nouns, verbs, etc. When complete print out the resulting silly story. Bonus points if you can load questions and story template from file.
- FizzBuzz. Create a program that prints numbers 1 to 100. However, if the number is a multiple of 3 print Fizz. If it is a multiple of 5 print Buzz, and if it is a multiple of both 3 and 5 print FizzBuzz.
- Word Scramble. Pick a word from a list of known words and randomly mix up the letters. User enters guesses of the original words and wins on a match.
- Slot machine/One armed bandit. Keep track of winnings and losses.
Ok, all I asked for was some simple challenge suggestions like a number generator and a list. Now that escalated quickly.
That was a no on the exercism thing right, or did it just get lost in the deluge?I'm sorry if I accidentally derailed the discussion by discussing programming tips instead of giving examples of simple programs to learn from. I didn't really start with smaller programs, rather I've just been working on (overly) ambitious projects for the past 2 years, so I shared, roughly, the way I learned SmileBASIC over time. I really hope we didn't leave a bad taste in your mouth!
No need to apologise, mate. I kinda wanted something like what they thought in school's computer classes and seggie pretty much hits the nail on the head with what I was looking for. Will go through everything posted here and take note of it somewhere. Might even post my solutions when and if I managed to achieve it.Ok, all I asked for was some simple challenge suggestions like a number generator and a list. Now that escalated quickly.That was a no on the exercism thing right, or did it just get lost in the deluge?I'm sorry if I accidentally derailed the discussion by discussing programming tips instead of giving examples of simple programs to learn from. I didn't really start with smaller programs, rather I've just been working on (overly) ambitious projects for the past 2 years, so I shared, roughly, the way I learned SmileBASIC over time. I really hope we didn't leave a bad taste in your mouth!
Update:
Print challenge done
Fahrenheit to Celsius and vice versa done (got the maths and inputs working but will have a look and give it more polish after work tomorrow.)
User input +age range is next on my list then I will play around with RND. Fizz Buzz sounds interesting and reminds me of a TIS-100 puzzle.
A game where you use button input (BUTTON()) to move around a sprite (SPSET & SPOFS) would be a good way to learn what makes SmileBASIC so different from other game development languages; sprites and input are massively simplified (for better or for worse).
Once you've mastered that, explore the other commands that are recommended in the editor when you type SP. Nearly all of them control sprites at varying levels of complexity. Try to shift the values modified by them with other buttons, such as ABXY, or the shoulder buttons.
On a side note, BG layers are also important if you plan on doing anything with a fancy backdrop. Similar to sprites, which have functions prefixed with SP-, background layers have functions which are prefixed with BG-.
Is there anywhere that explains SPCOL for beginners?SPCOL serves as a hitbox for sprites. You see, sprites has Width and Height that not only serves to define the size of the sprite, but also defines the size of the hitbox. If you use SPCOL, you will activate the hitbox, and since hitboxes don't interact with non-collisionable sprites (sprites that doesn't have an active hitbox), you have to activate their hitboxes as well.
'SPSET ID,U,V,Width,Height,Attribute SPSET 0,0,0,16,16,1 SPCOL 0,1 'The hitbox will have a size of 16x16, as defined on SPSET with the Width and Height valuesWhen a hitbox touches another sprite that also has a hitbox, it will return the ID of the sprite that touched it (by using SPHITSP). With that you can perform certain actions, for example, damage the player if touched a projectile or a spike, or "pickup" an item.
SPSET 0,0 'Strawberry SPSET 1,1 'Orange SPCOL 0,1 'Activate collision for Sprite 0 SPCOL 1,1 'Activate collision for Sprite 1 'If Sprite 0 touches Sprite 1, Sprite 1 will disappear IF SPHITSP(0)==1 THEN SPCLR 1However, hitboxes on SmileBASIC are, well, Basic. Something you have to realize is that certain special effects like SPROT or SPHOME won't affect the hitbox at all (with the exception of SPSCALE). Keep this in mind if you want to archieve accurate collision detection with scaled/rotated sprites. But well, SPCOL on most cases is what you need for this kind of stuff.
Perfect thank you so much!Is there anywhere that explains SPCOL for beginners?SPCOL serves as a hitbox for sprites. You see, sprites has Width and Height that not only serves to define the size of the sprite, but also defines the size of the hitbox. If you use SPCOL, you will activate the hitbox, and since hitboxes don't interact with non-collisionable sprites (sprites that doesn't have an active hitbox), you have to activate their hitboxes as well.'SPSET ID,U,V,Width,Height,Attribute SPSET 0,0,0,16,16,1 SPCOL 0,1 'The hitbox will have a size of 16x16, as defined on SPSET with the Width and Height valuesWhen a hitbox touches another sprite that also has a hitbox, it will return the ID of the sprite that touched it (by using SPHITSP). With that you can perform certain actions, for example, damage the player if touched a projectile or a spike, or "pickup" an item.SPSET 0,0 'Strawberry SPSET 1,1 'Orange SPCOL 0,1 'Activate collision for Sprite 0 SPCOL 1,1 'Activate collision for Sprite 1 'If Sprite 0 touches Sprite 1, Sprite 1 will disappear IF SPHITSP(0)==1 THEN SPCLR 1However, hitboxes on SmileBASIC are, well, Basic. Something you have to realize is that certain special effects like SPROT or SPHOME won't affect the hitbox at all (with the exception of SPSCALE). Keep this in mind if you want to archieve accurate collision detection with scaled/rotated sprites. But well, SPCOL on most cases is what you need for this kind of stuff.
I created the exercism.io app with coding exercises for SmileBasic that I was talking about earlier in the thread. 5RDXV3CJ if you want to check it out.
http://smilebasicsource.com/page?pid=886