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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:37:44+00:00 2026-05-26T04:37:44+00:00

Okay, so I’m calling a function that draws three lines to display an ‘I’

  • 0

Okay, so I’m calling a function that draws three lines to display an ‘I’ on-screen.
Then, I call another function which calls this function, but adds 1 to the x variable to
make a the letter bold. Then I want to put x++ add in the ‘tick’ function, which executes
every frame. It isn’t working, but why? If you don’t understand what I mean, please check this page, it’s the tutorial I’m following: http://www.devmaster.net/articles/intro-to-c++-with-game-dev/part3.php

Declare global x and y and call function tick:

int x = 0;
int y = 0;
void Game::Tick( float a_DT )
{
    m_Screen->Clear( 80 );
    DrawI(0,0);
    x++;
}

Making functions:

void Game::DrawI(int x, int y)
{
    m_Screen->Line( 100 + x, 50 + y, 200 + x, 50 + y, 0xffffff );
    m_Screen->Line( 150 + x, 50 + y, 150 + x, 300 + y, 0xffffff );
    m_Screen->Line( 100 + x, 300 + y, 200 + x, 300 + y, 0xffffff );
}

void Game::DrawFatI()
{
    DrawI(1,0);
    DrawI(0,1);
    DrawI(0,0);
    DrawI(1,1);
}

Thanks for checking.

  • 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-26T04:37:45+00:00Added an answer on May 26, 2026 at 4:37 am

    When you call DrawI it has x and y passed to it as parameters:

    void Game::DrawI(int x, int y)
    

    These mask the global x and y, such that within DrawI everywhere you say x and y it refers to the function parameters. (You can access the global ones using ::x and ::y though).

    Since you always call DrawI with literals, not variables, e.g. DrawI(1,0); the values of x and y in DrawI never change, they are always just these fixed values and not the global variable, hence Line is always passed the same values, even if your global x has changed.

    I would make two recommendations to avoid this:

    1. Don’t have multiple variables with the same name where one masks the other
    2. Don’t use globals, unless there’s a good reason to. (This doesn’t seem to be one as far as I can see)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, we know that the following two lines are equivalent - (0 == i)
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay, I have hundreds of .net controls with text attributes that needs to be
Okay so what I have is a table that keeps track of history on
Okay, so I'm trying to set a variable via a javascript method call. However
Okay getting some weirdness. I have a simple URLLoader in AS3 that loads an
Okay so I was helped earlier with my program question and found out that
Okay, URL Routing is great. Extensionless URLS, SEO friendly etc. However, it seems that
Okay, simple situation: I'm writing a simple console application which connects to a SOAP

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.