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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:30:39+00:00 2026-05-14T05:30:39+00:00

My game is a small shooting game in cocos2d. The enemy generates the bullets

  • 0

My game is a small shooting game in cocos2d. The enemy generates the bullets to shoot player at intervals of time. I have created a random y , so that bullets touch the opposite edge at random heights. If the bullet touches the player the enemy wins.
But, I need to set probability for the enemy accuracy. If the probability of enemy is given as 80% accuracy? How can I set in my program? For 10 shots 8 should be straight towards player.
How can I decide which ones should go straight in 10 which one should miss. In mean time player also shoots the enemy.

Thank You.

  • 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-14T05:30:40+00:00Added an answer on May 14, 2026 at 5:30 am

    I would do it like this.

    Assume your player has position y. To get 80% accuracy choose a random number from the interval [y - height*0.2, y + height*0.2], where height is the height of the screen. In general to get accuracy p choose a number from [y - height*(1-p), y + height*(1-p)]. When p = 1.0 (100%) then the bullet will be aimed at exactly the position of the player.

    This doesn’t mean that an enemy with 80% accuracy will fire 8 out of 10 shots exactly at the player, but the more accurate the closer the bullets are.

    This of course neglects the time bullet travels, but that can be included without that much work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have writing a small shooting game in cocos2d. Winning the game is to
I am writing a small game by using cocos2d. It is a shooting game.
I am writing a small shooting game using cocos2d. It's working good in simulator.
I have created a small game in Java and I would like to add
I'm creating a small game and I have a peace of code that collects
I'm writing a small game with Libgdx. I have aRender[OpenGL] thread that keeps calling
I have created a small game, in which some blocks are move around a
I'm making a small game and I have a character that can move in
I have small game engine written in c++. I'm considering using some features of
Ok guys just a small game: I have some specifications for a project. At

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.