Text-Based Space Simulator

This is a discussion on Text-Based Space Simulator within the Game Programming forums, part of the General Programming Boards category; Latly Ive been working on a space simulator called Vacuus. However I'm not sure how I could establish the player ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    41

    Text-Based Space Simulator

    Latly Ive been working on a space simulator called Vacuus.
    However I'm not sure how I could establish the player position, heres what I've done:

    I've created a pointer that points to a pacific location in a 2d array.
    Now what I want to do is let the player input 1 number , which will then change what ever the pointer was pointing in 1 dimension of the array. Does anyone know how to do that, or would I need 2 pointers?

    The mGame source can be found @ http://vacuus.hostrim.com/source_mgame.html

    The menu can be found @ http://vacuus.hostrim.com/source01.html

    Thx in advance

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    Well you probably won't be able to just inc/decrement the pointer address because the array won't be holding sequential memory locations (correct me if I'm wrong). But why cant you just do:

    Code:
    #include <stdio.h>
    
    int main(void)
    {
      int array[3][3] = {
                        1,2,3,
                        4,5,6,
                        7,8,9
                        };
    
      int *pointer = &array[0][0];
      printf("%d\n",*pointer);
      
      pointer = &array[2][1];
      printf("%d\n",*pointer);
      
      return 0;
    }
    Forgive me if I have totally mis understood you.
    Last edited by sand_man; 06-01-2005 at 07:25 AM.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    41
    Hmmm, never thought of that, thank you for your help.

    Also, does anyone know how to get into mode 13H? I've tried almost all of the code I could find on google, but still it wont work (said something about having to declare the registers:?)Any help would be appreciated
    Last edited by Nebbuchadnezzar; 06-01-2005 at 06:30 PM.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    You must have a DOS compiler.
    Code:
    void SetMode(void)
    {
      REGS regs;
      regs.x.ax=0x13;
      int86(0x10,& regs,& regs);
    }

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    41
    So that code wont work in Dev C++
    (heard it ould somewher, just tried it didnt work)
    Would DJGPP work
    Or is there away to get it to work in Dev C++?

    THX

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    DJGPP should work because it is a DOS compiler, but there still might be some trouble if you are not running it under DOS.

  7. #7

    Join Date
    May 2005
    Posts
    1,041
    People...still...use...that...mode...of...graphics ?


    *faints*

  8. #8
    C maniac
    Join Date
    Aug 2004
    Location
    Cyberwarping to Middle Earth
    Posts
    154
    As you can see by my avatar and my signture, I am a DOS programmer. Let me know if you want some help. I use DJGPP 2.03, on Windows 98. I test my programs on a Windows XP Home & Professional. I have a friend that ttests my programs for me. I have a VERY good gra[hics engine, called REDRAW_ENGINE. Actully, my brother made it for me. I use keyboard interrupts, timer interrupts.

    I can show you an example program:

    Code:
     #include "graphics.h"
     #include "interrupt.h"
     int main() {
    	 int x = 0;
    	 init_engine(0, 0);
    	 init_keyboard();
    	 graphics_screen_mode();
    	 while(!key_status[KEY_ESC]) {
    		 refresh_screen();
    		 x++;
    		 box(0, 0, 320, 200, x, set);
    	 }
    	 done_keyboard();
    	 return 0;
     }

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Referring to graphics mode 13h . . .

    People...still...use...that...mode...of...graphics ?
    All the time.

    *grins*

    dwk

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    It works on a certain 66MHz computer.

    But back on topic. Here's how you might change a position:

    Code:
    #define HEIGHT 5
    int array[HEIGHT][5];
    int *p1 = &array[2][2];
    int *p2 = p1;
    
    p1 += HEIGHT;
    p2 ++;
    
    /* now p1 points to array[3][2], p2 to array[2][3] */
    Be sure to put boundry checking in, too.

  11. #11
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    DJGPP works just fine for mode 13h. The exes it generates work on WinXP, 98 and 95 (66MHz). Although you have to slow it down a bit on WinXP . . . syncronizing to vertical retrace works really well.

  12. #12
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Mode 13h speed is based on the fact that each pixel is one byte. So a complete screen refresh is only 64kb, which even a 386 can do reasonably well.

    If you are using DJGPP, might I recommend jumping up to higher screen resolutions using int 10h Vesa BIOS Extensions. This will allow you to access the linear frame buffer, but you CANNOT use the near pointer hack inside of XP, it will fail at all times.

    You must use farnpokeb or some other derivative in DJGPP under XP to plot pixels.

    Ah..heck, dump DJGPP and use DirectX or OpenGL.

  13. #13
    C maniac
    Join Date
    Aug 2004
    Location
    Cyberwarping to Middle Earth
    Posts
    154
    I HATE DIRECTX! I installed it, and it killed the sound on my computer. After 6 months, I finnaly got it back. The video is way to slow, multi-player crashes, and it actully froze my computer when I ran my program. I lose 4MB every time I run a program. I have started with the SDL.
    Actully, I use DOS. I have a very good game (if anyone wants it . . . notify me) using DOS. It works on WinXP, Win95, and even Macintosh 84 (Windows 3.1).
    So, any other questions????


  14. #14
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    SDL is just a wrapper for OpenGL, IIRC.
    Away.

  15. #15
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    I thought Macintosh 84 was Windows 95.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 01-29-2008, 03:40 AM
  2. text based game
    By PippinofTook in forum Game Programming
    Replies: 5
    Last Post: 08-24-2005, 06:56 PM
  3. easiest way to make text based game?
    By oceanrats in forum C++ Programming
    Replies: 7
    Last Post: 08-13-2005, 02:17 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Text Based Game
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2002, 05:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21