Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    2d skateboard game

    Beginners
    18
    149
    20187
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • waldron
      waldron F @pianofire last edited by

      @pianofire right so if i
      drawImageEx( image, location, rotation, scale, tint, origin )
      scale = 1, 1
      this would work

      pianofire 1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team @waldron last edited by

        @waldron That would scale it to the original size. If you want it half size you would use { 0.5, 0.5 } and double size { 2, 2 }

        waldron 1 Reply Last reply Reply Quote 2
        • waldron
          waldron F @pianofire last edited by

          @pianofire got it, i know i should know this by now still coasting along but i think i got what i need now....

          pianofire 1 Reply Last reply Reply Quote 1
          • pianofire
            pianofire Fuze Team @waldron last edited by

            @waldron No problem. that's what we're here for

            waldron 1 Reply Last reply Reply Quote 1
            • waldron
              waldron F @pianofire last edited by

              @pianofire cheers, you could do a compendium of my questions for a idiots guide to coding haha
              at least others to embarrassed to ask can seek solace in my questions.

              Dave 1 Reply Last reply Reply Quote 2
              • Dave
                Dave Fuze Team @waldron last edited by

                @waldron That's exactly why every question should be asked without any embarrassment.

                You think your questions are daft? You should hear the list of questions I've asked @Luke throughout my learning journey...

                1 Reply Last reply Reply Quote 2
                • waldron
                  waldron F last edited by waldron

                  so iv managed to resize (scale) my character IMG (whoo hoo) but i'v also added a fore ground tile array so tiles appear over my character to add depth .. but this has also been effected by my scale
                  for my character as iv had to put the code in after the character to get this effect..
                  long story short, is there a way for the scale just to be targeted at my character and nothing else???

                  iv shared my game as (where im at) iv got 3 tile arrays
                  1 for collision
                  2 for background
                  3 for foreground

                  1 Reply Last reply Reply Quote 0
                  • Dave
                    Dave Fuze Team last edited by

                    @waldron I forget, are you using the sprite functions for your character? Or is it the drawSheet() style of doing things?

                    Either way, there are separate scale parameters you can apply to anything you like. drawSheet() has an expanded form, drawSheet( imageHandle, { sourceX, sourceY, sourceW, sourceH }, { destinationX, destinationY, destinationW, destinationH } )

                    That allows you to draw any portion of the original character image, at any scale, to the screen.

                    The drawImage() function also has an expanded form, drawImage( imageHandle, x, y, scale ). Using these expanded functions, you should be able to set individual scales for anything you need.

                    waldron 1 Reply Last reply Reply Quote 1
                    • waldron
                      waldron F @Dave last edited by waldron

                      @Dave the draw sheet, so under that iv got
                      scale = { 1.4, 1.4 }
                      how do i target it as it effects my 3rd tile array
                      i can work around it but think it will doom me later on

                      got ya cheers

                      1 Reply Last reply Reply Quote 0
                      • Dave
                        Dave Fuze Team last edited by

                        This is why it's generally best practice to use a single scale, consistently throughout your program. It can lead to difficulties if you've got things at different scales. That's hard to plan for though, especially when using entirely your own created graphics.

                        In the actual draw commands for the things you want to change, you could have a separate scale variable for the player:

                        playerScale = scale * 1.5
                        drawSheet( character, { 0, 0, width, height }, { playerX, playerY, width*playerScale, height*playerScale } ) // width and height refer to the pixel width and height of the source image
                        
                        M waldron 2 Replies Last reply Reply Quote 1
                        • M
                          MikeDX @Dave last edited by

                          @Dave said in 2d skateboard game:

                          This is why it's generally best practice to use a single scale, consistently throughout your program

                          That right there is such an important piece of advice.

                          1 Reply Last reply Reply Quote 2
                          • waldron
                            waldron F @Dave last edited by waldron

                            @Dave yeah iv already started painting my self into a corner with scales ect
                            find the sprite sheet not big enough to fit all my character and enemy animations in with this method
                            so iv had to draw them small to fit more in and scale them larger
                            with the other build i use sprites so no issue there as i can do separate sprite sheets to each animation
                            i want to do the same with this one but dont know how to handle the code to do separate sheets for my images .....
                            noob right here lol

                            1 Reply Last reply Reply Quote 0
                            • Dave
                              Dave Fuze Team last edited by

                              It's the same, except you don't need to use setSpriteImage(). Just replace the contents of the image handle with the spritesheet you want to use, before the sprite is drawn.

                              spritesheets = [
                                  loadImage("playerRunSheet"),
                                  loadImage("playerJumpSheet"),
                                  loadImage("playerTrickSheet")
                              ]
                              
                              run = 0
                              jump = 1
                              trick = 2
                              state = run
                              
                              
                              // then, in the main loop
                              sheet = spritesheets[state]
                              
                              drawSheet( sheet, {0, 0, w, h}, {x, y, w*scale, h*scale} )
                              

                              That is of course pseudo-code just intended to get the idea across. Let me know if you want me to expand on this or write more in detail.

                              waldron 1 Reply Last reply Reply Quote 1
                              • waldron
                                waldron F @Dave last edited by

                                @Dave thats great man im going to rework this game iv got all my assets so not to much of a bugger,
                                honestly cant thank you enough iv got that structure for the other build just didnt think it would work the same for this whoo hoo!!!!!

                                Dave 1 Reply Last reply Reply Quote 2
                                • Dave
                                  Dave Fuze Team @waldron last edited by

                                  @waldron Very glad to be of help dude! Give me a shout if you need anything :)

                                  waldron 1 Reply Last reply Reply Quote 0
                                  • waldron
                                    waldron F @Dave last edited by

                                    @Dave you'l regret saying that.. haha

                                    i'm getting used to adding my enemies in game now but how can i change there death state from
                                    collision/velocity (jumping into them) to a button attack (c.x) from my player?
                                    if i can master that i can then add animation to my level and crushing blocks and spikes coming out of walls ect but give them a state where they kill me

                                    1 Reply Last reply Reply Quote 0
                                    • Dave
                                      Dave Fuze Team last edited by Dave

                                      I think you could use multiple death states, each having their own specific spritesheet to draw from, and requisite conditions to trigger them. Something like:

                                      (Of course, this is pseudo-code)

                                      if collide with enemy and playerState != attack then
                                          enemyState = death1
                                      endif
                                      if collide with enemy and playerState == attack then
                                          enemyState = death2
                                      endif
                                      if enemyPosition overlaps with kill box then
                                          enemyState = death3
                                      endif
                                      

                                      There is probably a much more lovely way of doing this, but this is the route I would personally go down.

                                      Then, you'll have specific conditions for each of those death states:

                                      if enemyState == death1 and collides with player then
                                           // do specific things    
                                      endif
                                      
                                      waldron 1 Reply Last reply Reply Quote 1
                                      • waldron
                                        waldron F @Dave last edited by

                                        @Dave wonderful stuff cheers

                                        1 Reply Last reply Reply Quote 1
                                        • waldron
                                          waldron F last edited by

                                          I very nearly gave up, with all these ideas floating around my head trying to implement them all just caused confusion.

                                          So I stripped it back down to what I think I know and fixed all the confusion to something I can build on.

                                          With huge magnitudes of greatfullness for the fuze team and users.Thankyou!!!

                                          Tratax 1 Reply Last reply Reply Quote 4
                                          • Tratax
                                            Tratax F @waldron last edited by

                                            @waldron Awesome work man! This is really coming along!

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post