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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:46:45+00:00 2026-06-12T02:46:45+00:00

I am trying to create a map of a city using pygame. I want

  • 0

I am trying to create a “map of a city” using pygame. I want to be able to put images of buildings in specific grid coords rather than just filling them in with a color.

This is how I am creating this map grid:

def clear():
    for r in range(rows):
        for c in range(rows):
            if r%3 == 1 and c%3 == 1:
                color = brown;
                grid[r][c] = 1;
            else:
                color = white;
                grid[r][c] = 0; 
            pygame.draw.rect(screen, color, [(margin+width)*c+margin, (margin+height)*r+margin, width, height])         
    pygame.display.flip();

Now how do I put images of buildings in those brown colored grids at those specific locations? I’ve tried some of the samples online but can’t seem to get them to work. Any help is appreciated.

If anyone have a good source for free sprites that I can use for pygame, please let me know. Thanks!

this is the grid map i created

  • 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-12T02:46:46+00:00Added an answer on June 12, 2026 at 2:46 am

    Here’s an example I wrote. It uses a numpy to store tile data. The code plus image is downloadable at: http://code.google.com/p/ninmonkey/source/…/maptiles (If that fails, use this url: https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/ninmonkey/source-archive.zip )

    • Press S to toggle mouse scrolling.
    • Map.tiles is a 2d numpy.array that stores tile’s id

    tileset demo

    If you want to add units/sprites that are on top of the tilemap: (Your buildings might count as this)

    • store location using world coordinates
    • draw them using a world2screen coordinate function.

    The function will add the map offset to their world coordinates. So if the map offset is (-100,0) and your unit’s world coordinate is (0,0), you render at (-100,0) placing them a the top left part of the map, as expected, even though you are scrolled.

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

Sidebar

Related Questions

I'm trying to create an .on() method using events-map. I want to change this:
I'm trying to create a map of function names and function pointers using __stdcall.
I'm trying to create a map using gmap3.net plugin with Jquery, the script should
I was trying to create an app using Bing Map. in which i need
I am trying to create a custom google map using Longitudes and Latitudes that
I'm trying to create map (using the Google Maps JavaScript API V3 ) which
i am trying to create a Map Activity and i have been able to
I'm trying to create a map using Google Fusion Tables with two layers, one
I'm trying to create a simple map in androi (I want to add GPS
I am trying to create a map using two arrays. Here is the code:

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.