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 @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
                      • waldron
                        waldron F last edited by waldron

                        any idea how i can fix my points for tricks, at the moment iv assigned score to a button press (trick) but obviously the user can just sit there and rack up a huge score.

                        I thought i cracked it last night by putting in movement speed for the opposite direction while pressing the button which actually gave it a great effect of grinding to a halt but then starts moving in the other direction and breaks the effect.
                        so is there a way i can create a dead zone so i can keep this set-up but have the movement and score to stop once my character is not moving ? i can provide a video later to help explain

                        actually just figured out the movement thing by changing the direction of movement to y. axis.down so now i just need
                        the score fixing

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

                          @waldron I don't know if I'm following completely, but one thing I've been doing when I need a "cool down" is to have a global integer, then in my gameplay code I subtract it by one, and say "is it zero yet? if so, let them do action XYZ again".

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

                            @Spacemario i'l upload a video later altho a cool down does sound like a possible fix just don't know how i would code it,
                            my code from memory atm is kinda like

                            if c.y state = trick then
                            playerY movespeed -= // gives me the drag effect (slowdown)
                            playercoin += 1            // gives me the score 
                            .........so on so on 
                            
                            waldron 1 Reply Last reply Reply Quote 0
                            • waldron
                              waldron F @waldron last edited by waldron

                              @waldron said in 2d skateboard game:

                              @Spacemario i'l upload a video later altho a cool down does sound like a possible fix just don't know how i would code it,
                              my code from memory atm is kinda like

                              if c.y state = trick then
                              playerY movespeed -= // gives me the drag effect (slowdown)
                              playercoin += 1            // gives me the score 
                              .........so on so on 
                              

                              Tony hawks gets round this issue with balance bars

                              f71514a8-8118-416b-9459-c0c384138b45-image.png

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

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

                                  level is getting rather large now think im at 350 columns in length, really want to start introducing moving platforms i thought i could use the data from my enemy's and modify it but still proving to be a problem with my ability to code.and help would be greatly appreciated

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

                                    I would have thought moving platforms would pretty much be enemies too. But instead of dying when you collide with the top of the sprite you just land on it. Maybe a little more complicated in that you need to detect just the top of the sprite(s), not the bottom or sides but beyond that I don't see a lot of difference.

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

                                      @Martin il keep tinkering with the code, i got rid of the gravity so i have it floating and moving as of now
                                      using this

                                           if enemies[i].state != death then
                                              enemies[i].velocity += gravity
                                              if !collision( x + eSize.x / 2, y + eSize.y + enemies[i].velocity / eSize.y ) then
                                                  enemies[i].y += enemies[i].velocity / tSize
                                              else
                                                  enemies[i].y = int( ( enemies[i].y + enemies[i].velocity / tSize + eSize.y / tSize ) ) - eSize.y / tSize
                                                  enemies[i].velocity = 0
                                              endif
                                              if playerX + pSize.x > x and playerX < x + eSize.x and
                                                  playerY + pSize.y > y and playerY < y + eSize.y and
                                                  enemies[i].state == active and velocity > 0
                                              then
                                                  enemies[i].state = death
                                              endif
                                          endif
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • waldron
                                        waldron F last edited by

                                        wanting to rebuild my game using the level editor but having problems with the sprite camera following the player

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

                                          Does centreSpriteCamera(player.x, player.y) not cut it ?

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

                                            @Martin il test later that should do it, for another game im working on how would i manage the camera scrolling screen by screen

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