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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:00:15+00:00 2026-06-08T11:00:15+00:00

Small problem I’m having where I have an amount of objects (enemies) on the

  • 0

Small problem I’m having where I have an amount of objects (enemies) on the screen at one particular time and cannot redefine their value. I set my enemies to begin with 3 on the screen.

My objective is to change the amount of enemies based on the current score.

I’ve attached snippets of the code below.

#define kEnemies 3

- (void) EnemyIncrease 
{
    if (self.score>=100) {
    #define kEnemies 4
    }
}

// I’ve also tried amongst other things

#define kEnemies 3

- (void) EnemyIncrease
{
  if (self.score >=100) {
    #undef kEnemies
    #define kEnemies 6
  }
}

Would really appreciate some assistance.


I have now changed my code to the following

int numberOfEnemies;

if (self.score>=0) {
 numberOfEnemies = 3
}

else if (self.score>=100) {
 numberOfEnemies = 4
}

however the issue now is that the array does not update the numberOfEnemies when the score meets the new condition.

for(int i = 0; i < numberOfEnemies; i++)

Apologies I’m still new to coding and trying to modify existing code

  • 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-08T11:00:20+00:00Added an answer on June 8, 2026 at 11:00 am

    Macros are preprocessed, that means that they are processed before the rest of your code is even compiled.

    Taking out your code, that means the preprocessor sees this (using your second example). Ultimately, the value of kEnemies is 6:

    #define kEnemies 3
    #undef kEnemies
    #define kEnemies 6
    

    It’s not really viable to use #defines for variables, I only use them for constants.

    You could use a member variable:

    int numberOfEnemies;
    
    ...
    
    if (self.score >=100) 
    {
        numberOfEnemies = 6
    }
    

    (I removed the k prefix as this style is intended for constants)

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

Sidebar

Related Questions

I'm having a small problem in Java. I have an interface called Modifiable. Objects
i am having a small problem with my android application. I have some mp3
I have a small problem but cannot figure out why. On my django shell:
I am having one small problem with my code. I am sending a POST
I'm having a small problem making a query in MySQL. I have the following
have small problem, and would very much appreciate help :) I should convert byte
I have a small problem and I've figured out where when and why it
I am having a small problem with the Magento quick search. When I search
I have a small problem which i can't seem to figure out. I tried
I got a probably small problem using memcmp. I have two arrays (length =

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.