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 7970235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:22:00+00:00 2026-06-04T07:22:00+00:00

I am writing a very quick mini game, and I don’t have any vector

  • 0

I am writing a very quick mini game, and I don’t have any vector implementation for it. This is what I have:

local qx = manx
        local qy = many
        local px = bigenemyx
        local py = bigenemyy
        local vx = qx - px
        local vy = qy - py
        local mag = math.sqrt(vx^2 + vy^2)
        bigenemyx = bigenemyx + mag * speed * dt
        bigenemyy = bigenemyy + mag * speed * dt

bigenemy needs to follow man. bigenemy just disappears off the screen. I’ve rushed the code for this and am (evidently) not experienced with the maths in this, thanks for any help – apologies if I just haven’t thought straight, I haven’t really stuck to “more speed less haste”!

  • 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-06-04T07:22:01+00:00Added an answer on June 4, 2026 at 7:22 am

    Well, you are using ‘mag’ value in all directions – it is not good. Try

        if(mag < 0.0001): mag = 1
        bigenemyx = bigenemyx + (vx/mag) * speed * dt
        bigenemyy = bigenemyy + (vy/mag) * speed * dt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a very simple game engine for an assignment and to make
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I have a very simple question about menu control in Android. I'm writing a
I have very small and quick question. Is it neceseary for all the developers
Quick question. I have a client with an HTML based website which ranks very,
I'm writing very processor-intensive cryptography code (C#), so I'm looking for any performance gains,
I am writing this game with hundreds of levels, but in one of my
Here is the problem... I'm writing very small plugin for Blender, I have 10
I am writing a very performance intense program and have been using C, but
Very quick question - I'm writing a basic script which updates a table based

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.