UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: ScottB on January 27, 2025, 02:52:23 PM

Title: Puzzel Game
Post by: ScottB on January 27, 2025, 02:52:23 PM
Here is the start of a small pipe puzzle game.
Once the pipes match a path you win.
I was wondering how to make graphics better.
They already are 3x3 pipes for each piece.
So how do I Stretch a graphic and rotate it the same.
each has 4-way rotation.
You can change tile number from 1 to say 1,2,3,ect...to get a new graphic. yes but
each must rotate 4 way like it already does. pipes just look square right now.

Any ideas..

Thanks

ScottB

 
Title: Re: Puzzel Game
Post by: kevin on January 27, 2025, 08:10:49 PM
If you want to animate tiles then all you need do is create sprites from the tiles are that being animated (moved rotated/scaled whatever). 


The process would be something like this;


 User selects tile to rotate around

 --> scan the map for the what tiles are to be animated/moved. 

 -->  For each tile that is set to 1

 -----> compute start & ending map coordinates of this tile. So where is's coming from and where it's moving to.   

 -----> set the map to zero at this tiles starting location, as It's going to be drawn separately from the main screen.

 -----> Add each tile to a list of dynamic moving objects.  These objects would store the starting position of the tile and expected end position of the tile and the tile ID, but in this case there's only one tile type (that being 1).  

 

 During each screen refresh we draw the list / array of sprites.  Each time updating their new position / rotations / Scale accordingly before drawing it.  Do this until the sprite reaches the expected target position.  

 --->  When the sprite reaches the target, we draw the sprite in it's last position, just to make sure the player sees the tile animte all the way from from position A through to Position B on the map entirely

 --->  Write the end tile position back into the map

 --->  delete now unwanted dynamic sprite   



Existing Screen Shot of the code above:
Title: Re: Puzzel Game
Post by: ScottB on January 28, 2025, 07:55:51 AM
I sort of know what you mean.  Is there a way you can show me an example of this?
Thanks
ScottB
Title: Re: Puzzel Game
Post by: kevin on January 28, 2025, 08:35:42 AM
What part ?

Here's a short example of using a list to manage a list of moving objects ( images / sprites)

Press the mouse button to create a moving object. The object will move from the RIGHT handle of the Mouse position to the left hand side of the mouse position.  It's movement will be in a semi circle, moving through 0 to 180 degrees.

[pbcode]

    setfps 60


    type tAnimatedObject
            X#,Y#
            Angle#
            Speed#
            Colour
    endtype

    Dim object as tAnimatedobject list

    do
        cls
       
        mx=mousex()
        my=mousey()
        mb=mousebutton()

        if mb=1
            Object = new tAnimatedobject

            Object.Angle    =  0
            Object.Speed    =  4.45
            Object.Colour    = rndrgb()
            flushmouse
        endif


        print "press mouse to create dynamic object"

        // draw a circle at mouse position       
        circle mx,my,50,true


        for each object()
           
            angle#=Object.Angle
            // Animate object
            object.X#=mx+cos(angle#)*100
            object.Y#=my+sin(angle#)*100
            circlec object.x#,object.y#,50,true,object.colour
            angle#+=object.speed#
            Object.Angle=angle#
            print angle#
            if (angle#>180) then Object = null
        next   
        Sync
    loop

[/pbcode]