Posted: 24th Oct 2021 19:03
A bit of a weird sliding action while on the platform


I know, I tried every physics function to boot and still slides, I tried setting sprite mass real high and this made the swing , swing all around non stop lol, it was a funny this to watch.

just a shame that sprite does not have a "grab" animation


I wish I was a artist, but I will soon be looking for a artist who can use what I bought and hopefully make a couple more animations for me.

Your jump physics look 100% better, still a tad high


Well It is odd, how things work differently in my phone and on the pc, I have to adjust it for each and as i am testing I just keep it like it is. same for my walk and run, on my phone real fast, to fast, on my pc just the right amount. so I have this set for my pc to test it.

Again your levels look great


Thank you, a lot of hard work.
Posted: 24th Oct 2021 19:46
I tried every physics function to boot and still slides


Is your player now set dynamic or kinematic?

I would need to test to confirm but once the player lands on the platform the physics engine should take care of the position, if its dynamic, kinematic you would need to lock its position <<< brain fart << not really sure

one way to go about it is use GetWorld*FromSprite to get the correct position on the platform and (in this case) override the physics to set the player position.

Its an interesting mechanic that I have never done before so from the get go you already done better than me, lol

I wish I was a artist


Yeah, "Game Art 2D" free stuff does not come with the SCML file, if you buy a premium pack you get the body parts and SCML file then you can make any animation you want in Spriter, the IK is already setup on the rigs adding new animations is pretty easy, its worth the investment.
Posted: 24th Oct 2021 20:29
if you buy a premium pack


I have a monthly download premium membership and I have all the sprinter parts with license for each player the guy and Girl. I just don't know anything about sprinter lol.

one way to go about it is use GetWorld*FromSprite


I might just try to use set sprite position or set sprite movment to o, let me look at it and work it out, something to do today.
Posted: 24th Oct 2021 20:53
Ah ok well if your subscribed and get the full package it would really benefit you to learn Spriter, there is a wealth of information out there on how to use it, its not an overly complicated program but does have a small learning curve, I have a few of their packs (Mechs and Soldiers) but never used them.

I have this weird thing that I want to learn a program or system, I learn it and get good and then find something else I want to learn, its good because I know many API's, IDE's and systems but bad because I never get anything done!!

set sprite position or set sprite movment to o


In that situation its probably the best solution, only the player will still need to move on the platform but thats easy enough to code in, as you say just use SetSpritePosition only while on a oscillating platform overriding the physics engine and reinstate the physics when the player jumps off the platform.

This should be doable in just physics code but right now I am not sure how to go about it.... depends on the settings and will most likely break something else... the joys of coding, huh! lol
Posted: 24th Oct 2021 21:46
its good because I know many API's, IDE's and systems but bad because I never get anything done!!


And this is why I don't want to do anything else.

I am a programmer, that is all I want to be.

I know some big time Programmer's who work along with artist's who make many big programs because they work together. Now all i need is a good artist to work along with me and we can create many good applications and make a business out of it.

Small time artists work by them self and sell there art for small amounts and do ok, but artists that want to grow find good programmer's to work with and I'm hoping soon I can find the same.

It is funny because I just watched a video of the team who created crash bandicoot years ago and they only had two in the team, the programmer and the artist.
They did everything just for the game and became a team together for years after that.
Posted: 24th Oct 2021 22:17
On another note

I can not for the life of me figure out what ray cast from just the top of the player to the bottom of the rock would be

+ Code Snippet
Hit = PhysicsRayCast(  PX# ,PY#,RockX#,-RockY#)
Posted: 24th Oct 2021 22:33
seems you're doing something different than Grounded (ie, checking a single rock?)
but, maybe:
+ Code Snippet
Headed = PhysicsRayCast( PX#,PY#,PX#,PY#-17)
Head = GetRayCastSpriteID()
Posted: 24th Oct 2021 22:39
seems you're doing something different than Grounded


Nope just in my PhysicsRayCast, thanks I will try it but I can not get a hit other then under the rock. this is what I'm trying to achieve.

This is the whole thing

+ Code Snippet
                PX# = GetSpriteXByOffset(Player)	:	PY# = GetSpriteYByOffset(Player)
                RockX#=GetSpriteXByOffset(Rock)
                RockY#=GetSpriteYByOffset(Rock)
  
                Hit = PhysicsRayCast(  PX# ,PY#,RockX#,-RockY#)
Posted: 24th Oct 2021 23:01
Virtual Nomad

That fixed it so simple in the end lol

+ Code Snippet
   If GetSpriteFirstContact(Player)
        Repeat
			    Headed = PhysicsRayCast( PX#,PY#,PX#,PY#-17)
                Head = GetRayCastSpriteID()
                ThisHit = GetSpriteContactSpriteID2()
                If ThisHit &gt; 0 and Rocks.Find(ThisHit) &gt; -1 and Head=ThisHit
                Rock = Rocks.Find(ThisHit)
                
                If Rock &gt; -1 and Rocks[Rock].Coins &gt; 0 And Rocks[Rock].LastCoin# + 0.20 &lt; Timer() 
                    SpawnCoin(ThisHit)
                    Rocks[Rock].Coins = Rocks[Rock].Coins -1
                    Rocks[Rock].LastCoin# = Timer()
                    playsound(sound_2)	
                 
                   inc coins,1
                EndIf
            EndIf
        Until GetSpriteNextContact() = 0
    EndIf
Posted: 24th Oct 2021 23:19
i havent implemented it yet myself but a few examples ago i realized that Contacts vs Rays might be best (where there is now redundancy). ie, get all contacts then get positions/directions relative to px#/py# to determine "ground", "head", "left/right", etc for full 360 deg coverage.

it might have to do with experience with contacts in 3d/bullet which are tricky but i was hesitant to use box2d contacts because of said experience. but, it's worth exploring, so...

in the end, whatever works then, ideally, whatever works BEST.
Posted: 24th Oct 2021 23:52
Contacts vs Rays might be best


Well this is a ray with a contact together and it works great.

ideally, whatever works BEST.


Amen to that
Posted: 25th Oct 2021 2:45
I have been looking for that Artist for over a decade!

A small tip for code optimization

This:
+ Code Snippet
If GetSpriteFirstContact(Player)
     Repeat
             Headed = PhysicsRayCast( PX#,PY#,PX#,PY#-17)
             Head = GetRayCastSpriteID()
             ThisHit = GetSpriteContactSpriteID2()
             If ThisHit &gt; 0 and Rocks.Find(ThisHit) &gt; -1 and Head=ThisHit
             Rock = Rocks.Find(ThisHit)
              
             If Rock &gt; -1 and Rocks[Rock].Coins &gt; 0 And Rocks[Rock].LastCoin# + 0.20 &lt; Timer() 
                 SpawnCoin(ThisHit)
                 Rocks[Rock].Coins = Rocks[Rock].Coins -1
                 Rocks[Rock].LastCoin# = Timer()
                 playsound(sound_2)  
               
                inc coins,1
             EndIf
         EndIf
     Until GetSpriteNextContact() = 0
 EndIf


You call Rocks.Find(ThisHit) in the if statement and then again after by setting the Rock variable, call it once before the IF and use the variable in the IF, this might seem a bit OCD to some saying "but modern computers bla bla bla" but in a massive project if you did this kind of thing on every if, loop and function you will cripple the FPS and have your users flaming you on Steam ...

Rule of thumb, if an array lookup is going to be used more than once in a section of code put it in a variable, var access is far far less expensive than array lookups, also self auditing is very very important, I don't believe in "if it works its good" that is a bad attitude and one that will lead to failure, write the function, get the code working and then study the living daylights out of it to find ways to improve and speed it up.

Good programmers write code that works, great programmers write code that works fast

You seem like a smart determined person and a fast learner, I am sure you will get there, if you find that artist, give him my number! lol

i was hesitant to use box2d contacts because of said experience


Your intuition is correct there is a very well documented fault in Box2D "the ghost vertices issue" that occurs when a box shape slides over another box shape, think a square player sprite sliding over a tilemap with individual collision shapes for the tiles, sometimes the edges can catch on "ghost vertices" and register a collision
Posted: 25th Oct 2021 4:29
I have been looking for that Artist for over a decade!


Yes there hard to find unless you pay them upfront then even after that your not guarantied good quality.

You call Rocks.Find(ThisHit) in the if statement and then again after by setting the Rock variable,


Well I am using the same code Virtual Nomad wrote up as a example.

You seem like a smart determined person and a fast learner, I am sure you will get there, if you find that artist, give him my number! lol


Thank you
Posted: 26th Oct 2021 1:21
I have a small problem

I create my rocks and coins with this array

I then hit each rock and then the coins delete.

I then walk and my ground is also deleted

Somehow my invisible ground for collision is in the same array but it is not.

+ Code Snippet
For x = 0 to 18

        ThisRock.ID = CreateSprite(Grid1)   :   SetSpriteSize(ThisRock.ID,10,10)
        
            SetSpritePhysicsOn(ThisRock.ID,1)   :   SetSpriteGroup(ThisRock.ID,-10)
            inc m,105
            if m=&gt;700 then inc m,200.0
            if m=&gt;900 then inc m,50.0
            if m=&gt;1700 then inc m,300.0
            if m=&gt;1900 then inc m,50.0
            SetSpritePhysicsFriction(ThisRock.ID,0.00005)
        ThisRock.Coins = (Random(0,8))
    Rocks.InsertSorted(ThisRock)
Next x


This is me creating my ground

+ Code Snippet
ground_0=createsprite(0)
setspritesize(ground_0,5000,10)
setspriteposition(ground_0,0,90)
setspritephysicson(ground_0,1)
SetSpriteTransparency(ground_0,1)
SetSpriteColorAlpha( ground_0,50 )
SetSpriteVisible (ground_0,0 )



How is my ground being mixed in with a set array?

Edit:::

This is how I'm deleting the coins in its own array.

+ Code Snippet
    For x = MyCollectedCoins.Length to 0 Step -1
		if GetSpriteExists(MyCollectedCoins[x].ID)
        inc MyCollectedCoins[x].Timers
        if MyCollectedCoins[x].Timers=&gt;40
        SetSpritePhysicsOff(MyCollectedCoins[x].ID)
        endif
        
        if MyCollectedCoins[x].Timers=&gt;50
         DeleteSprite(MyCollectedCoins[x].ID)
         MyCollectedCoins[x].Timers=0
         endif
        EndIf
    Next x
Posted: 26th Oct 2021 2:47
How is my ground being mixed in with a set array?

i don't see where it is. where else are you deleting sprites?

unrelated:
+ Code Snippet
            inc m,105
            if m=&gt;700 then inc m,200.0
            if m=&gt;900 then inc m,50.0
            if m=&gt;1700 then inc m,300.0
            if m=&gt;1900 then inc m,50.0

at some point, m => 700 then it's immediately 900, then 950 (all at once).
later, it's 1700 and immediately 2000, then 2050 (again, all at once)
i dunno what m might be but i'm pretty sure you don't want all that going on.
maybe m should use select/case vs if statements so it's only processed once at a time?

add: obviously that code is familiar but i used step -1 because when i wrote it, i also .removed the index from the array (along with deleting the sprite it referenced).
you're not doing that (.remove) so at some point that index is refilled with another sprite ID? or, recreated later with the SAME sprite ID?
Posted: 26th Oct 2021 2:50
Maybe try
+ Code Snippet
For x = MyCollectedCoins.Length to 0 Step -1
    if GetSpriteExists(MyCollectedCoins[x].ID)
    inc MyCollectedCoins[x].Timers
    if MyCollectedCoins[x].Timers=&gt;40
    SetSpritePhysicsOff(MyCollectedCoins[x].ID)
    endif
     
    if MyCollectedCoins[x].Timers=&gt;50
     if MyCollectedCoins[x].ID = ground_0
         Message("Coin ID is same as ground at "+str(x))
     endif
     DeleteSprite(MyCollectedCoins[x].ID)
     MyCollectedCoins[x].Timers=0
     endif
    EndIf
Next x
Posted: 26th Oct 2021 3:43
unrelated:


So I want to position each rock in some x pos and not so I change the x pos for those places, it works good.

.remove


I'm not sure and if so I need to look at it better, that would be my bad. That is a probability.

blink0k

That's a good idea, I will try it just to play around with it.

But to be honest I was more confused on why my ground is in my array and I think Virtual Nomad Answered this.

Ok edit:

I added this to my code

MyCollectedCoins .remove()

And it works
Posted: 26th Oct 2021 4:24
unrelated:


it works good.


What Nomad is trying to tell you is

this line (if m=>700 then inc m,200.0), sets m to 900 and the next line (if m=>900 then inc m,50.0) sets m to 950 so m=900 never makes it into your code

and the same for the next 2 lines

if this is the behaviour you want then (if m>=700 then m=950) gives the same result and saves CPU cycles, again, same for the next 2 lines

and please don't say "well it works so its fine", we are trying to help you here, we know code, we know how it works and we can do basic math and that block of code makes no sense!, did you read anything I posted about self auditing?

use elseif
+ Code Snippet
inc m,105
if m=&gt;700 
	inc m,200.0
elseif m=&gt;900 
	inc m,50.0
elseif m=&gt;1700
	inc m,300.0
elseif m=&gt;1900
	inc m,50.0
endif
Posted: 26th Oct 2021 5:09
we know how it works and we can do basic math and that block of code makes no sense!, did you read anything I posted about self auditing?


It does work, it places every rock where I want and not in the places I don't want.

m=900 never makes it into your code, is because I am not finished with the code, I stopped there till I am ready to put in new rocks.

But I will try your elseif any how because it looks like a better way to do it.

Thanks for your input.

I am real close to finishing level 2

I have some pretty cool things I am going to add soon.


Edit:

But I looked and found im not using that any longer my bad lol.

I am now doing this

SetSpritePosition(Rocks[0].ID, 130, 20)
Posted: 26th Oct 2021 5:47
It does work


I didn't doubt for a second that it does exactly what you want it to do, just pointing out the obvious flaw in the block trying to help make you a better coder.

But I will try your elseif any how because it looks like a better way to do it.


Well better is subjective, depends on the use case

if you are checking the same variable multiple times (within a range) then use a elseif, for static values use a select statement, for a single argument/function check (if something then) is fine, it really depends on what values you are evaluating

one of the fundamental principles of coding is instinctively knowing what to use where ... this will come with experience, and good advice form forum members

Edit:

But I looked and found im not using that any longer my bad lol.


Meh!, I have many projects that have unused blocks of code left over from testing, it happens, don't sweat it.