Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Tail Smash! - Arcade driving game  (Read 234 times)

0 Members and 1 Guest are viewing this topic.

TobBot2

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Tail Smash! - Arcade driving game
« on: March 02, 2024, 09:23:20 pm »
Hey! I've been working on this game over the course of a bit over a month. Check it out on itch - https://tobbot2.itch.io/tail-smash

Source code is available GitHub here if you're interested (it's not pretty though) https://github.com/TobBot2/TailSmash




Let me know if you've got any questions on development whether it be technical or conceptual :)


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
Re: Tail Smash! - Arcade driving game
« Reply #1 on: March 04, 2024, 12:39:47 pm »
That's a pretty cool mechanic! :)

Without having to dig through the code, what math did you use for the tail physics?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TobBot2

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Tail Smash! - Arcade driving game
« Reply #2 on: March 05, 2024, 06:09:22 am »
Just some inverse kinematics based off of a coding train video I saw a while back. The main logic was coded while I was in a plane (my brother challenged me to an in-flight game jam, which kicked off the project), so I couldn't look it up at the time lol but I guess I remembered enough to have it function convincingly enough.

For those unfamiliar with inverse kinematics, (or at least how I implemented it)... Basically, at the start of each update, it just moves the first node to the car's position, then it moves the next node so its distance to the first node is constrained to the chain segment's set length. Then it repeats that move + distance constraint for all subsequent nodes.

Here's a some pseudo-code of the the function Player::updateChains() in Player.cpp
for all chain nodes (starting from the car, iterating until the ball):
        node.position += node.velocity
        node.velocity += frictionForce
       
        if distance(node.position, node.parent.position) > chainSegmentLength:
                // segment := vector pointing from parent to node, with length set to chainSegmentLength
                Vector2 segment = (node.position - node.parent.position).setLength(chainSegmentLength)
               
                // node.velocity = new position - old position
                node.velocity = node.parent.position + segment - node.position
               
                node.position = node.parent.position + segment
 

As I write this, I'm realizing I'm not applying delta time correctly... Yeah, I kind of took the mentality of "There are two types of code. Good code, and production code."

But it works well enough! I might come back to this project later when I've got more time to rewrite all the code and implement some of the features I withheld to combat scope creep.

 

anything