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

Just random questions to help me make a game

Root / General / [.]

legofordmnCreated:
I would use a computer, but mine is freakin' slow Just saying. EDIT: Also what's up with all of this just saying stuff?

I don't know. XD

Ok, so I have a question. I've written a program where if you push a certain button, it will load a specific Sprite, but after it loads, I want it so if I push other buttons, it will move the Sprite around. How would you do that?

I would use SPUSED. So
IF SPUSED(sprite number) THEN move sprite ELSE SPSET sprite info

Is there a way to do this with using custom sprites?

Look into using the SPOfs command to "Offset" the position of your sprite.

Is there a way to convert photos into sprites on SmileBasic 3?

Yes, there is. But it isn't an easy task, if you're already finding the rest of this difficult. Baby steps, learn as you go, but don't try to do the really hard stuff until you're ready. (Don't run before you can walk. Don't fry the fish until you've caught it. etc..) Use your GoogleFu, and see if you can find the solution. But it won't be easy, and you'll likely find it too hard to understand. If you can't, then I suggest you continue your program without the photo, for the meantime. Later on, you might be able to figure it out, but first, work on the rest of the task. Maybe draw a silly smiley clown face, and use that until you can manage the photo stuff. Don't ever let an inability to understand stop you from achieving your goal, but do make sure that you understand the things you're doing. Make yourself little challenges as you go. They help learn things. Try creating a new project, and see if you can rewrite as much of this as you can, without looking back. Train, learn, and you'll gain enough XP to level up and get the photo stuff working!

Assuming it's a BMP, JPG, or PNG, you can use the tools included with PetitModem (http://smilebasicsource.com/page?pid=812).

Is there a way to have something happen when two sprites hit each other?

Is there a way to have something happen when two sprites hit each other?
Yes.
'Create a sprite and setup collision
SPSET MN,PN'Managment number, number on the sprite page.
SPCOL MN'Enable collision detection

WHILE 1'Game loop
COLLISION=SPHITSP(MN)'Check collision
IF COLLISION!=-1 THEN GOSUB @COLROUTINE'Branch if it collided with something
WEND

@COLROUTINE
'Put code here to run when the sprite collides.
RETURN
The COLLISION variable will give you the management number of the sprite it collided with, so you can, for example, have a block of code execute when it your player sprite collides with a door. If there isn't collision, this value is -1. So, by checking if it isn't -1, you can have code execute any time your sprite collides with another sprite.

What is the simplest drawing program that you can make in a game?

Wdym?

Like, what is the best way to make a simple drawing program, where if you push a button, a sprite will appear in that spot, and then be able to do the same thing somewhere else on the map.

I dunno.

WHILE 1
IF #UP==BUTTON(3) THEN DEC SLY
IF #DOWN==BUTTON(3) THEN INC SLY
IF #RIGHT==BUTTON(3) THEN INC SLX
IF #LEFT==BUTTON(3) THEN DEC SLX

'Making sure the cursor stays on the screen.
IF SLX<0 THEN SLX=0
IF SLX>49 THEN SLX=49

IF SLY<0 THEN SLY=0
IF SLY>29 THEN SLY=29

'Convert tile locations into on-screen coordinates.
PX=(8*SLX)
PY=(8*SLY)
IF #A==BUTTON(3) THEN SPOFS SELSP,PX,PY
WEND
Also, if you don't know the answer to something, it's best to just not respond. If he's asking a question and you don't know the answer, there's no point in responding to it. It's not helping anyone and it just fills the activity feed with useless posts. A more elegant solution would be to create a tile buffer array (50 by 30), but using this code you should be able to accomplish that without too much trouble. Also, be sure to have some sprite initialization code before this code. Otherwise, it will throw an error.

Ok, so I am making a very simple and small game where you can drive a car across the screen. I have already gotten it to move, but I want the car to flip around once I start driving in the opposite direction. Could someone teach me how to do this?

if button()==#down then reverse 'if down on the d-pad is pressed, exec instruction reverse
def reverse'defines the instruction
sprot 0,180' rotates sprite id 0,change 180 if it dosent rotate properly
end

You might want to look into is COS and SIN. You seem to have movement down, just based off of your words, but if you want swag car controls, I can’t recommend these awesome functions more. They can return the speed on each axis that a sprite should move at based on an angle and a speed. Y has made a resource about this. https://smilebasicsource.com/page?pid=971 As for rotating the sprite, SPROT will work. But again, if you aren’t using SIN/COS, then that rotation can look really choppy. The only logical step forward for smooth rotation in that situation is to use SPANIM, but that’d be really hard to figure out. Like how could you smoothly rotate the sprite and have it’s rotations perfectly match it’s movement? It’s not possible to get that perfect, and it’s really hard to get it to look decent. So yet again, if you want smooth rotation, I recommend SIN/COS.
Make sure you’ve read Y’s awesome resource.If you end up using SIN, COS, and SPROT, it shouldn’t be too hard to figure out how to rotate the sprite itself. If you store the angle as a radian, you could just SPROT 0,RAD(ANGLE). And if you store it as degrees, then you can do this:
SPROT 0,ANGLE’Rotate sprite
GET_SPEED ANGLE OUT V_X,V_Y’Get velocity

DEF GET_SPEED ANGLE OUT X,Y
 VAR R_ANGLE=RAD(ANGLE)’Convert degrees to radians
 X=COS(R_ANGLE)
 Y=SIN(R_ANGLE)
END
Hope that helps.