Navigation

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

    2d skateboard game

    Beginners
    18
    149
    20197
    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 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
                      • waldron
                        waldron F @Spacemario last edited by waldron

                        @Spacemario Want to be able to move up and down y axis but hitting collide map. Want it like the simpsons game style.
                        Ignore background still building the level.alt text

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

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

                            just like this

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

                              @waldron I think I might know what the problem is! In my game, I was setting player speed to 0 when they collided with the map hit boxes. Then, when the player would overlap such a hit box, they'd be "stuck". So, I added some code to set their speed to like 10, and reverse their angle, so they'd "bounce" off the hit box-- and that gave me the desired effect.

                              At one point, I had the "rebound speed" too low, and they would "vibrate" on the collision box and be stuck-- does any of this apply to your game, maybe it's a similar issue?

                              Your game reminds me most of "Skate or Die 2"-- back in like first grade, my best friend and I used to play the heck out of it on his NES. Looking back now as an adult, it's a pretty evocative game-- very atmospheric, and the Rob Hubbard soundtrack is great!

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

                                @Spacemario instead of the bounce effect, I think you can use the player coords (player.x, player.y) and their last position. something like (oldPlayer.x, oldPlayer.y) and if the player collides with an axis, just set the location of the player to the old coordinates.

                                if collision on x axis then
                                player.x = oldplayer.x
                                endif

                                and at the end of your instructions for drawing the sprite have:

                                oldplayer.x = player.x
                                oldplayer.y = player.y

                                Something along those lines i think...

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

                                  @Spacemario that could actually work for me if i applied up and down with their own properties /gravity
                                  il have a mess

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

                                    @lawyerlounge i thought about this route but think its above my coding experience il look into it
                                    im only 3 weeks in to coding.

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

                                      thinking if i just plotted my player in the middle no gravity then i can freely move and just have gravity for jump and have collide at the bottom and top

                                      1 Reply Last reply Reply Quote 0
                                      • lawyerlounge
                                        lawyerlounge last edited by lawyerlounge

                                        what do you mean by "in the middle NO gravity" and then "just HAVE gravity for jump"?

                                        Like having moving upwards on the y axis and jumping doing the same just at a different rate while jumping?

                                        waldron 2 Replies Last reply Reply Quote 0
                                        • waldron
                                          waldron F @lawyerlounge last edited by

                                          @lawyerlounge position my player in the middle of the screen, if i have no gravity the player will sit in that position and i can freely move it around.
                                          to jump and have the player/sprite come back down apply gravity to that button press???? no idea mate

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

                                            @lawyerlounge its not a game breaker i can either have that mechanic or not or just add it later if needs be would be nice to get it working shouldn't be as hard as it seems

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