0 Members and 2 Guests are viewing this topic.
Well first off, if you want realistic pysics, you might want to consider switching to x256 format. This is where every time you add 256 to your position variables, your character moves 1 pixel. This will allow you to have more precision and possibly get the gravity effects you are looking for.However, If you do not want to use x256 format and stick with what you have, you can try this simple physics piece of code:Code: [Select]:Lbl G:Θ*3+GDB0->r5:If {r5+3}>>-7:{r5+3}+1->{r5+3}:End::{r5+1}+{r5+3}->{r5+1}:While sub(GN,{r5}+5,{r5+1}+5:If {r5+3}>>0:{r5+1}-1->{r5+1}:Else:{r5+1}+1->{r5+1}:End:End::If sub(GN,{r5}+5,{r5+1}+5)=0 && getKey(4):-7->{r5+3}:End:ReturnThis piece of code *should* give you some realistic gravity and jumping in your game
:Lbl G:Θ*3+GDB0->r5:If {r5+3}>>-7:{r5+3}+1->{r5+3}:End::{r5+1}+{r5+3}->{r5+1}:While sub(GN,{r5}+5,{r5+1}+5:If {r5+3}>>0:{r5+1}-1->{r5+1}:Else:{r5+1}+1->{r5+1}:End:End::If sub(GN,{r5}+5,{r5+1}+5)=0 && getKey(4):-7->{r5+3}:End:Return
Pt-Change(X/256,Y/256,Pic0)
Quote from: Builderboy on February 08, 2011, 11:17:44 amWell first off, if you want realistic pysics, you might want to consider switching to x256 format. This is where every time you add 256 to your position variables, your character moves 1 pixel. This will allow you to have more precision and possibly get the gravity effects you are looking for.However, If you do not want to use x256 format and stick with what you have, you can try this simple physics piece of code:Code: [Select]:Lbl G:Θ*3+GDB0->r5:If {r5+3}>>-7:{r5+3}+1->{r5+3}:End::{r5+1}+{r5+3}->{r5+1}:While sub(GN,{r5}+5,{r5+1}+5:If {r5+3}>>0:{r5+1}-1->{r5+1}:Else:{r5+1}+1->{r5+1}:End:End::If sub(GN,{r5}+5,{r5+1}+5)=0 && getKey(4):-7->{r5+3}:End:ReturnThis piece of code *should* give you some realistic gravity and jumping in your gameYour code don't work, no gravity affect my worms, and I don't understand what does it mean.
It's basically where your X and Y values are inflated (multiplied) by 256 for greater accuracy. In other words, when you actually display it, you'd useCode: (Axe) [Select]Pt-Change(X/256,Y/256,Pic0)To move one pixel, then, you'd add 256 to either X or Y.The point here is to simulate "half-pixels" and other fractions for the motion to seem smoother. For example, you could have the character move 1.5 pixels every frame by adding 384 to X instead of 256.
Sqrt((X-I)^2+(Y-J)^2)=D
(X-I)^2+(Y-J)^2=D^2
abs(X-I)->r1*^r1+(abs(Y-J)->r1*^r1)->D
If K<<0
K**N+A->AK**O+B->B
K**N*3//2+A->AK**O*3//2+B->B
If abs(X-I)->r1*^r1+(abs(Y-J)->r1*^r1)<MI-X//L->NJ-Y//L->OA**N+(B**O)*-1->KIf K<<0K**N*3//2+A->AK**O*3//2+B->BEndEnd
Code:Lbl MSK{r2^8+{r2/8*W+(r1/8)+L1}+Str1}e r1ReturnWhere r1 is your X position, r2 is your Y position, W is the width of your tilemap (in tiles), L1 is the location of your matrix data buffer, and Str1 is the start of your Mask Sprite table.
How do you use tile masking with 5 by 5 tiles rather than 8 by 8 tiles?
Where r1 is your X position, r2 is your Y position, W is the width of your tilemap (in tiles), L1 is the location of your matrix data buffer, and Str1 is the start of your Mask Sprite table.