Yo Gan I changed the 5th card in the demo and it did some weird crap with the forces. The ball tends to want to roll one way more so then the other like there's wind and then when you press down while it's on the ground it flys up and to the left. ??? Maybe you should just try this out in Key Down on #5 and see fo yoself.
IF Key$ = UPARROW$ THEN
ApplyLinearImpulse 1, 0,0.1, 0,0
END IF
IF Key$ = DOWNARROW$ THEN
ApplyLinearImpulse 1, 0,-0.5, 0,0
END IF
IF Key$ = LEFTARROW$ THEN
ApplyForce 1, -0.5, 0, 0,0
END IF
IF Key$ = RIGHTARROW$ THEN
ApplyForce 1, 0.5,0, 0,0
END IF
I have some tough decisions I need your help to make.
Do you want me to get rid of the world boundaries? I can make the level infinite so if you want boundaries you'll have to manually make them.
Should CreateCircle/CreateBox/CreatePolygon return the shape number? It might make it easier to track shapes:
LET player = CreateCircle 30, 10, 10, 0.2, 0.2, 0.2, "Dynamic
ApplyTorque player, 18
Anything you guys want me to add or change?
I made some code for a ship which I calibrated to work by tapping keys to work around SC's key down issue, and it worked fine on a box with these same traits. But when I made it a triangle it drew it and it wouldn't move. What would cause the physics to freeze?
LET player = CreatePolygon( "0,0;15,40;30,0", 100, 100, 0.2, 0.1, 0.6, "Dynamic", 0)
SetFixedRotation player, TRUE
EDIT: While I'm asking questions how do I make it respond to a collision? There is no "if shape a touches shape(s) b".
EDIT 2: OMG GAN'S MAKING DEFENSE GAEM
OK I will, I have to get off the computer now, I was just uploading this test, about the transfer of energy. The one on the left works like in real life and the desk toy failed horribly. XD
But it's funny to watch, anyway.
https://sites.google.com/site/onronc/Experiments.scproj?attredirects=0&d=1
EDIT:
Updated it. The pendulum works now, I just make them way denser.
And I found out that while objects with sprites on them are moving in my case it lags like you wouldn't believe and impedes user input. I had to let the balls settle before it stopped and I could quit out. So it WAS the whole program, Matt. Thing is I didn't have that problem with your example. ???
EDIT 2:
workaround, for those who had trouble:
ON TIMER 2
MOVESPRITE 1, shapex(1)-25, shapey(1)-25, TRUE
MOVESPRITE 2, shapex(2)-10, shapey(2)-10, TRUE
MOVESPRITE 3, shapex(3)-25, shapey(3)-25, TRUE
UPDATESCREEN
END TIMER
As a note, I didn't make a velocity demo so...
When making a shape you:
SetGetVelocity myShape, TRUE
That makes it so you can access velocity. Now to get the velocity you:
PRINT "X Velocity=" + STR$(shapeXVel(myShape))
PRINT "Y Velocity=" + STR$(shapeYVel(myShape))
PRINT "Rotational Velocity=" + STR$(shapeRotationVel(myShape))
I have it set up this way so the game runs fast. You set a shape to get velocity, then you just grab the velocity number from the array.
Hey Gan, if two shapes are touching when you start a physics world then as soon as they aren't there's a glitch in EndCollision. It's easy to re-create, it worked with a circle and a polygon or a circle and a circle.
And what's wrong with this polygon? Maybe I'm just tired but the physics wouldn't start.
I made the points with my brand new Object Builder, which I will upload as soon as I'm sure it works and is not the problem here.
LET polygon = CreatePolygon( "40,361;160,361;200,241;0,241", 100, 100, 0.2, 1, 0.1, "Dynamic", 0)
I just tried this out for the first time. Amazing shit right here.
I think a proper plugin system would be awesome for v2.1 even if it was Mac only (plugins made in Cocoa). REALbasic supports something called IPC which is more appropriate than regular sockets and I bet Cocoa supports this too.
Instead of having to launch the plugin and do all this other crap, the plugin would be rebundled from a .app into a new .scplugin format that you would add to a Plugins folder. Inside the bundle would be a file that describes all of the methods that the plugin adds to the game, including their parameters and return types so that they can be added to auto-complete.
In addition the game would support getting and setting variables by the plugin, as well as access to almost any method that the game has access to.
If a game uses a plugin it would be bundled into the game automatically, launched when the game starts and exited when the game stops.
In this model the plugin would be persistent and have it's own memory etc like a normal program. There's also another way we could do it that doesn't involve IPC at all but would actually be even cooler and closer to the REALbasic model. Instead of a program you would be writing a dylib. The dylib would expose a number of generic functions that would be identical between all SC plugins. REALbasic can weak link to libraries and I could set it up to weak link to say, 50 different plugins named SCPlugin1.dylib, SCPlugin2.dylib, etc. so up to 50 dylib plugins would be supported. Instead of using IPC Sockets (with a latency of maybe 1 ms) we could just use declares/method calls with a much smaller latency... just an idea I've been throwing around in my head.
Another idea I had for really really easy to make plugins would be SCMethodBundles which would be nothing but a group of methods that you save out of a project into a file, and then drag into the Plugins folder of SC. If you use any of the methods then it would link in the whole bundle. You still have to worry about overlapping variables though, consider this problem which can happen even in a regular game using methods:
FOR i = 1 to 10
SOMEMETHOD
NEXT
SOMEMETHOD Code:
FOR i = 1 to 5
PRINT "Hello"
NEXT
That code will cause infinite loop.
Made it:
Test Dylib.dylib (http://cl.ly/3z2L0s3f1s1h1Q0X0m0P)
Hope I made it right, couldn't find any tutorials. This dyblib contains one class: Test.h & Test.m
In the class there are 3 things you can do:
-(void)beep;
-(void)giveInt:(int)num;
-(int)takeInt;
Is this all you need?
I got a question again:
ON TIMER 2
MOVESPRITE 1, shapex(player)-25, shapey(player)-25, TRUE
rotatesprite 1, shapeRotation(player)
UPDATESCREEN
END TIMER
I looked in InitializePhysics and I found these arrays.
I'm curious why it works for x and y and not rotation. ???
PS this didn't lag at all, is what you're doing more complex somehow?
EDIT: This polygon doesn't crash the plugin but it acts funny when I drag a small box inside it or into the sides:
LET verts$ = "80,30;160,30;180,130;160,130;140,50;100,50;80,130;60,130"
LET cup = Create Polygon( verts$, 200, 150, 1, 0.3, 0.1, "Dynamic", 0)