Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:31:32+00:00 2026-05-28T00:31:32+00:00

What I basically am going for is a platform game where you can advance

  • 0

What I basically am going for is a platform game where you can advance through stages by getting past enemies and such. You will get different weapons as you advance and pick things up. I would like for these different weapons you pick up to be able to be pointed in the direction that the mouse is currently at.

Since it’s a little hard to example it right I found a video that pretty much shows exactly what I want but with a different sprites used.
http://www.youtube.com/watch?v=8W7WSkQq5SU

So lets say this is the image I would use for one of the weapons:
Pickaxe

How would I go about adjusting it (pseudo code) to make the right point of the pickaxe be pointed in the same direction of the mouse?

I just looking for some pseudo code of how you may go about doing this the most efficient way and the smoothest way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:31:33+00:00Added an answer on May 28, 2026 at 12:31 am

    If you are using Java Graphics2D then you have to use AfflineTransform. To do this first translate to the point of the axis of your pickaxe. Then you would rotate by the direction to the mouse which can be found using atan2. then you draw the axe so the offset matches the axis point.

    Pseudocode:

    #function drawAxe:
        translate(player.x, player.y);
        translate(pickaxis.x, pickaxis.y);
        rotation=toDegrees(atan2(mouse.y-player.y,mouse.x-player.x));
        rotate(roation);
        translate(-axisPointOnPickaxe.x, -axisPointOnPickaxe.y);
        drawImage(pickaxe.texture);
        IdentityMatrix();//[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]] or no transformation. i think you have to set a blank transform to do this in java efficiently
    #endFunction drawAxe
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I’ve heard that certain conditions will cause .NET to blow past the finally
Please help me with this code - I am basically going through a book
Basically my issue can be seen by going here using internet explorer. works perfectly
Basically I'm going to go a bit broad here and ask a few questions
Basically I've got some structs of type Ship which are going to go on
My site is going to have a credit system that basically works a lot
Basically, I would like a brief explanation of how I can access a SQL
I haven't seen this before in a query, basically what is going on here?
I know that cross platform GUIs can be built in Ruby using various tools
This is more of a PHP design question. Basically, I'm going to have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.