Navigation

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

    2d skateboard game

    Beginners
    18
    149
    20201
    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.
    • Tratax
      Tratax F @waldron last edited by Tratax

      @waldron hey - have updated the code and favourited the edits with some suggestions, re-shared this if you want to take a look.

      The way i think of it is the skateboard always running in a state of movement, initiliasing the movement speed lower and utilising an "acceleration" variable as a multiplier in small increments that increases to a max or decreases to a negative max depending on how fast you want to go only when the buttons are held

      The else condition highlighted then exists for the purpose if nothing is presssed to reduce that acceleration variable until it reaches 0 - may need to be split out as I didnt try this with left movement you could use your c. left and right to count up or down on that multiplier possibly

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

        Also, it's got a great feeling, keen to see how this progresses!

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

          @Tratax legend thank you il have a gander now cheers man

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

            @waldron All good! worth noting the camera movement speed also has the acc multiplier attached so that it can correctly match the speed of your skater

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

              @Tratax great work man perfect, yes could go either way with this keep as is and keep flowing in one direction or fix the left to do the same as the right.
              cheers man

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

                @waldron said in 2d skateboard game:

                @Tratax great work man perfect, yes could go either way with this keep as is and keep flowing in one direction or fix the left to do the same as the right.
                cheers man

                btw your intros are fantastic to your games i still need to figure out how to load from intro to main game...

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

                  @waldron Thanks, the way I'm doing it still experimental and I'm not sure if its best practice but as everything is carried out sequentially, I try to take advantage of that.

                  Example:

                  // Call my intro/title function before the main game loop
                  // Once this breaks, it then moves into the main game loop
                  
                  doIntro() 
                  
                  
                  // Main game loop
                  loop
                       .. Main game code goes here 
                       update()
                  repeat
                  
                  
                  // All my functions live at the bottom of the code
                  function doIntro()
                  loop
                       clear()
                       ..
                       .. Do your fun title code here
                       .. 
                       c = controls( 0 )
                       if c.a then
                            break
                       endif
                       update()
                  repeat
                  return void
                  
                  
                  
                  1 Reply Last reply Reply Quote 1
                  • waldron
                    waldron F last edited by pianofire

                    This post is deleted!
                    waldron 1 Reply Last reply Reply Quote 0
                    • waldron
                      waldron F @waldron last edited by pianofire

                      Update, more tricks, more level drawn and forward motion roll thanks to tratax!
                      Lots more moves/tricks to come.

                      1 Reply Last reply Reply Quote 9
                      • spikey
                        spikey F last edited by

                        I am impressed, reminds me of California Games. Also it was a BMX discipline there. It looks like this will be as fun as well.

                        1 Reply Last reply Reply Quote 2
                        • Juggalo_Jesus
                          Juggalo_Jesus last edited by

                          This is looking AWESOME. Keep up the good work!

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

                            so im at the point where im updating this whole game with every thing iv learnt so far anything i learn after i will make a 2nd game in the series but for this one im wanting to add 2 other elements im not sure on how to implement..

                            1.entering end of level - to level 2, entering house/shop screen
                            kind of know how to do it but is there a better way?

                            House()
                            Endlevel1()
                            Shop()
                            thinking of creating an item that il mask in the screen so... black door way with black item
                            collect = said item then house.

                            2.slopes collision edge detection so player can move diagonally on a 2d game

                            Spacemario 1 Reply Last reply Reply Quote 0
                            • B
                              Bl4ckM4ch1n3 last edited by

                              You don't necessarily need to create an item to collect to go to the house. You cold simply add a door sprite and check if the player collided with the door. Then you know you'll need to load / display your house.

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

                                @waldron I just implemented board switching in my game last night! What I did was define each board in an array, with a sub-array containing all of the sprite definitions for that level. By "definitions", I mean the X and Y coordinates of each sprite, the type (such as "teleporter"), and (for teleporters) the destination board and X-Y coordinates, for when the player touches the teleporter.

                                I have a function called "switchMap()", which grabs the appropriate board element, loops through the definitions for that stage, and populates the level. It does this by creating and adding sprites to an "actors" array, mapping over the properties from the definition to the sprite (so the teleporter sprite will have properties like "targetX", "targetY", "targetBoard", etc.).

                                This all makes my "draw()" function trivial; it just loops through the "actors" array and draws each sprite according to the properties. Adding a new element to a board takes like ten seconds: just copy and paste an array entry in the board's "definitions" sub-array. Done!

                                In my main game loop where I'm checking for sprite collisions, if the 'currentSprite.type == "teleporter"', I call my "switchMap()" function, which unloads the current map, loads the "sprite.targetBoard" one, resets the player's X and Y coordinates to "sprite.targetX / sprite.targetY", and boom-- the player is now on the new map, in the correct spot.

                                I even have "switchMap()" switch the background music to the correct song, which I have in a property in my "boards" array. I have a working transition between a city "overworld" and a sewer "dungeon", and it was really gratifying the first time I could leap between the two at will.

                                Hope that helps at least somewhat!

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

                                  @Spacemario wow thankyou so much for the detailed comment great help thanks

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

                                    @waldron Sure thing! Let me know if you run into any questions.

                                    Incidentally, I'll be working on my game tonight-- I found a bug yesterday, where I am accidentally doing an operation on an unloaded sprite in my "actors" array (crash!), but only after switching boards 3-4 times. I'm sure it's a simple bug in my logic, but it's odd that I need to switch boards multiple times for it to manifest. Weird!

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

                                      @Spacemario cheers im reanimating my character atm but might start laying down framework for the level switches sure il be needing your help again haha thanks man

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

                                        @waldron I fixed my weird bug a couple of hours ago! I had code something like this:

                                        for i = 0 to len(actors) loop
                                            curSprite = actors[i].sprite
                                        
                                            removeSprite(curSprite)
                                            ….
                                        repeat
                                        

                                        For some reason, that "curSprite" variable was referencing a sprite other than "actors[I].sprite", because the crash error was telling me, "you can't remove a sprite which has already been removed, you dolt!"

                                        So, I replaced all references in my loop to "curSprite" with "actors[i].sprite", and the code worked.

                                        Next step: the HUD.

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

                                          @Spacemario glad you got it working man,
                                          I'm trying to get y axis movement atm but character vibrating on the collision map lol

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

                                            This post is deleted!
                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post