Thread: How to move a sprite around inside a windows GUI

  1. #1
    Web Developer
    Join Date
    Mar 2005
    Location
    Vancouver, Canada
    Posts
    24

    How to move a sprite around inside a windows GUI

    Hey guys,

    I was wondering how to go about making a sprite move from position X to Y with a mouse click on a windows GUI?

    I just want to know what kind of API's to use....because I have no idea. Coding wise, I should be able to figure it out, hopefully, and if I don't, I'll post what I have.

    The reason for trying to learn how to move an object (a shape of somesort) across the screen of a GUI is that me and my friends want to make a small game.

    Any help would be greatly appreciated!

    Kind regards,
    JB
    Jaime Bueza
    Bueza Web Development
    "Ingenuity without sacrificing accessibility, efficiency, or quality."


    University: British Columbia Institute of Technology (BCIT)
    Program: Computer Systems Technology
    Specialization: Relational Database Systems
    Term: 2 / 4

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Look into the GDI. You can do this by First loading a bitmap with LoadBitmap or another image function and then selecting it into a device context (CreateCompatibleDC/SelectObject).
    Once you have it you can you bitblt() to transfer the image to the device context of you main window, this is best done in response to WM_PAINT.
    Using the windows gdi is ok for a small game but a real game would use a graphics library like directx or opengl

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    just as a recomendation, Micheal Morrison's, "Teach Yourself Game Programming in 24 hours" specifically covers what you are looking for.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Using the Windows API for this is like trying to build a house with a rubber mallet.

    You will do yourself a big favor if you use a graphics API. Most of the crapola you have to do in API has next to nothing to do with graphics and more to do with the confounded API and it's use of DC's.

  5. #5
    Web Developer
    Join Date
    Mar 2005
    Location
    Vancouver, Canada
    Posts
    24
    Would any of these packages help me out then?

    http://www.devpaks.org/list.php?category=GUI
    Jaime Bueza
    Bueza Web Development
    "Ingenuity without sacrificing accessibility, efficiency, or quality."


    University: British Columbia Institute of Technology (BCIT)
    Program: Computer Systems Technology
    Specialization: Relational Database Systems
    Term: 2 / 4

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Yeah - GTK is a good bet.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows Gui Question
    By Kyrin in forum Windows Programming
    Replies: 7
    Last Post: 05-21-2006, 07:28 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. Creating a database (inside a GUI)
    By goosematt in forum C Programming
    Replies: 7
    Last Post: 10-23-2003, 11:04 AM
  4. How do i make my sprite move?
    By Hyperganon in forum Game Programming
    Replies: 9
    Last Post: 09-14-2002, 01:21 PM
  5. Windows GUI
    By orufet in forum C++ Programming
    Replies: 3
    Last Post: 09-04-2001, 05:45 PM