? How to make à library (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
What's going on?? See: Site Update March 2022

How to make à library

  • #1 ✎ 41 Heredos Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself I'm a beginner on smile basic and I'm trying to make à platformer https://smilebasicsource.com/page?pid=1346 I need help beacause write collisions take à lot of memory and are sooooooooooooooooo long to write Thanks for tout help Posted
  • #2 ✎ 1559 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Avatar Taboo I didn't change my avatar for 180 days Website
    I'm a beginner on smile basic and I'm trying to make à platformer https://smilebasicsource.com/page?pid=1346 I need help beacause write collisions take à lot of memory and are sooooooooooooooooo long to write Thanks for tout help
    Ok I saw the program. I'll try to think of a way. I don't know at the moment.
    Posted Edited by rando
  • #3 ✎ 1559 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Avatar Taboo I didn't change my avatar for 180 days Website K I found a way to do maps using DATA and easy graphic screen collision. I'll finish a demo and send you the key tomorrow. Posted
  • #4 ✎ 1559 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Avatar Taboo I didn't change my avatar for 180 days Website Key: N3FEZXD3 Try to look at how I used GSPOIT to detect ground pixels around the player (the circle) It will help. Posted
  • #5 ✎ 41 Heredos Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself No, I juste want know how to use common def. I've make an unworking test here QKXN4J96 Posted
  • #6 ✎ 1559 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Avatar Taboo I didn't change my avatar for 180 days Website
    No, I juste want know how to use common def. I've make an unworking test here QKXN4J96
    lol I didn't understand the question You have in a different slot your COMMON DEF or you could just put DEF in your normal slot. If you want to make a library for this game that other people can use, you should do COMMON DEF in the other slot. You use both of these in the same way, but on COMMON DEF you put common before DEF on the same line and have it in a different slot. Here is a simple tutorial to use these: COMMON DEF DOSOMETHING SPSET 0,0 SPANIM 0,"XY",-10,0,0,-10,0,8,-10,8,8,-10,8,0,0 END'When you call DOSOMETHING in your code, a sprite will appear and move around. COMMON DEF ILIKEPIE V1'Now we can add arguments SPSET 0,0 IF V1==0 THEN SPANIM 0,"XY",-10,0,0,-10,0,8,-10,8,8,-10,8,0,0 ELSE SPANIM 0,"R",-10,360,0 END'If you run ILIKEPIE 0 then the sprite will move around. If you put the same thing with any other number, it'll rotate. You could tack on more arguments, you just need to put a comma between them. EDIT: I sad now it deleted half of my stuff when I pasted it in (it said "The form requires a session ID and one wasn't received" and I C/P'd and reloaded.)
    Posted Edited by rando
  • #7 ✎ 115 Sam Amazing Page Hidden Achievements Great Page Hidden Achievements Good Page Hidden Achievements I tried coming up with something simplified enough. You can use this function as many times as you want in your code before X=X+VX and Y=Y+VY. Remember to replace the variable names with your own! 'X and Y are your player coordinates, VX and VY are the player's velocities, R is the player's radius, and X1 to Y2 are your rectangle coordinates DEF RECT_COLLISION X,Y, VX,VY, R, X1,Y1,X2,Y2 'If you're inside the rectangle IF X+VX+R>=X1 && X+VX-R<X2 && Y+VY+R>=Y1 && Y+VY-R<Y2 THEN 'If coming from the left IF X+R<X1 THEN X=X1-R-1:VX=0 'If coming from the right IF X-R>X2 THEN X=X2+R:VX=0 'If coming from the top IF Y+R<Y1 THEN Y=Y1-R-1:INAIR=0:VY=0 'If coming from the bottom IF Y-R>Y2 THEN Y=Y2+R:VY=0 ENDIF END(EDIT) I looked at your failed attempt: the problem is that with your code, you don't actually check from which direction the player is coming. If the X velocity is positive, it doesn't necessarily mean that you're coming from the left; it just means you're moving to the right. My take on this is to check if the player's previous position was to the left of the rectangle. There are probably other ways to handle this. Posted Edited by Sam
  • #8 ✎ 212 seggiepants My exercism.io ported code makes use of several source files. You can check out that if you want to see common def in use. I had planned to do a platformer tutorial series at one point but no one was interested. http://smilebasicsource.com/page?pid=886 Key: 5RDXV3CJ Posted
  • #9 ✎ 1559 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Avatar Taboo I didn't change my avatar for 180 days Website
    My exercism.io ported code makes use of several source files. You can check out that if you want to see common def in use. I had planned to do a platformer tutorial series at one point but no one was interested. http://smilebasicsource.com/page?pid=886 Key: 5RDXV3CJ
    platformer tutorials? YES please do it
    Posted
  • #10 ✎ 41 Heredos Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself
    I tried coming up with something simplified enough. You can use this function as many times as you want in your code before X=X+VX and Y=Y+VY. Remember to replace the variable names with your own! 'X and Y are your player coordinates, VX and VY are the player's velocities, R is the player's radius, and X1 to Y2 are your rectangle coordinates DEF RECT_COLLISION X,Y, VX,VY, R, X1,Y1,X2,Y2 'If you're inside the rectangle IF X+VX+R>=X1 && X+VX-R<X2 && Y+VY+R>=Y1 && Y+VY-R<Y2 THEN 'If coming from the left IF X+R<X1 THEN X=X1-R-1:VX=0 'If coming from the right IF X-R>X2 THEN X=X2+R:VX=0 'If coming from the top IF Y+R<Y1 THEN Y=Y1-R-1:INAIR=0:VY=0 'If coming from the bottom IF Y-R>Y2 THEN Y=Y2+R:VY=0 ENDIF END(EDIT) I looked at your failed attempt: the problem is that with your code, you don't actually check from which direction the player is coming. If the X velocity is positive, it doesn't necessarily mean that you're coming from the left; it just means you're moving to the right. My take on this is to check if the player's previous position was to the left of the rectangle. There are probably other ways to handle this.
    ok but if xv= 0 then the player don't move
    Posted
  • #11 ✎ 115 Sam Amazing Page Hidden Achievements Great Page Hidden Achievements Good Page Hidden Achievements Sorry, the code I gave you doesn't really work... To apologize for being so lazy, instead of just writing you code on here, this time I took the time to test it in your game and make you a new version. I modified your program so it only relies on one function for collisions, like you wanted. Some other small modifications:
    1. I made the skip to the title screen only happen after the initialization (when you skip the cutscene in your current version, it doesn't clear the screen or load the font!) I can't force you to, but I would really really recommend using ACLS instead of manually resetting things. It makes sure everything is reset to default.
    2. I renamed your RADIUS variable "R" and replaced all of the "10"s in your code with R
    Here's the key: QKF5ZXRD (Note to people reading in the future: I will unpublish this eventually, so don't bother)
    Posted
  • #12 ✎ 41 Heredos Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Thanks you sooooooo much Sam, m'y code Can be optimized now thanks you. I will change some things but you are already in the credits Posted