Ошибка необработанного исключения Visual Studio 2012 и Allegro 4

Турция

Я использую allegro 4.4.2 в Visual Studio 2012 для школьного проекта. Allegro установлен и работает, и я пытаюсь заставить его загрузить файл map.txt, который находится в папке проекта. При отладке allegro зависает и становится невероятно медленным и выдает необработанное исключение, нарушение кода доступа ко мне.

Это Map.h:

#include <allegro.h>
#include "Global.h"
#include <fstream>
using namespace std;

class Map
{
    public:
         Map();
        ~Map();


        void Init();
        void Update();
        void Draw(BITMAP *Buffer);

        void LoadMap (const char*filename);
    private:
        int loadCounterX;
        int loadCounterY;
        int mapSizeX; 
        int mapSizeY;
        int MapFile[20][15];
};

А это Map.cpp:

#include "Map.h"

Map::Map()
{
}


Map::~Map()
{
}

void Map::Init()
{
    loadCounterX = loadCounterY = 0;
    Map::LoadMap("map1.txt");
}

void Map::Update()
{

}

void Map::Draw(BITMAP *Buffer)
{
    for (int i = 0; 1 < mapSizeX; i++)
    {
        for (int j = 0; j < mapSizeY; j++)
        {
            if (MapFile[i][j] == 1)
            {
                rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, makecol(0, 255, 255));
            }
            else if (MapFile[i][j] == 2)
            {
                rectfill(Buffer, i*BlockSize, j*BlockSize, i*BlockSize + BlockSize, j*BlockSize + BlockSize, makecol(0, 255, 0));
            }
        }
    }
}

void Map::LoadMap(const char*filename)
{
    ifstream openfile (filename);
    if (openfile.is_open())
    {
        openfile >> mapSizeX >> mapSizeY;
        while (!openfile.eof())
        {
            openfile >> MapFile[loadCounterX][loadCounterY];
            loadCounterX ++;

            if (loadCounterX >= mapSizeX)
            {
                loadCounterX = 0;
                loadCounterY ++;
            }
        }
        loadCounterX = loadCounterY = 0;
    } //File is opened
    else
    {
        allegro_message ("Map File couldn't be found");
    }
}

а вот и мой основной файл:

#include <allegro.h>
#include "Player.h"
#include "Global.h"
#include "Camera.h"
#include "Map.h"
using namespace std; 
volatile int counter = 0;

void Increment ()
{
    counter ++;
}

int main (void)
{
    allegro_init();
    install_keyboard();
    install_mouse();
    install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "A");
    set_color_depth(32);
    set_gfx_mode (GFX_AUTODETECT_WINDOWED, ScreenWidth, ScreenHeight, 0, 0);

    LOCK_VARIABLE (counter);
    LOCK_FUNCTION (Increment);
    install_int_ex (Increment, BPS_TO_TIMER(100));

    BITMAP *Buffer = create_bitmap (6000, ScreenHeight);
    bool done = false;

    Player player;
    Camera camera;
    Map map;

    player.Init();
    camera.Init();
    map.Init();

    while (!done)
    {
        while (counter > 0)
        {
            //Input
            if (key[KEY_ESC])
                done = true;

            //Update
            map.Update();
            player.Update();
            camera.Update(player.x, player.y);
            counter --;
        }

        //Draw
        map.Draw(Buffer);
        player.Draw(Buffer);
        camera.Draw(Buffer);
        clear_bitmap(Buffer);
    }
    return 0;
}
END_OF_MAIN();

На этой строке происходит сбой

if (MapFile[i][j] == 1)

каждый раз. Все переменные, показанные в «Авто» в Visual Studio, становятся красными; «MapFile» «MapFile [i]» (чего я не понимаю .. разве это не должно быть просто «i»?) «J» «mapSizeY» и «this» Однако, когда я раскрываю «MapFile», первый 20 блоков заполнены правильно, как в моем файле map.txt. Я полностью потерялся и понятия не имею, что делать ... любая помощь приветствуется!

Саймон Кремер

В void Map::Draw(BITMAP *Buffer)использовании 1 < mapSizeXвместо i < mapSizeX.

Вы также можете запретить вызов, Map::Drawесли ранее Map::LoadMapне был вызван.

Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.

En caso de infracción, por favor [email protected] Eliminar

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

Error de excepción no controlada Visual Studio 2012 y Allegro 4

¿Puedo usar Allegro en Visual Studio 2017?

Visual Studio 2012 Ultimate Edition с записью веб-теста

DBContext не распознается в Visual Studio 2012 Express для Интернета

Cambiar de Visual Studio-2012 a Visual Studio-2010

Find all commented line in visual studio 2012

Porting Visual Studio VSPackage to SSMS 2012 or 2014

disable error sounds visual studio 2012

Razor intellisense not working in Visual Studio 2012

Referencia que no funciona en Visual Studio 2012

Error loading Visual Studio 2012 and 2015 projects

Visual Studio 2012 no carga ningún proyecto

Usando Java con Microsoft Visual Studio 2012

generador de consultas visual studio 2012

Visual Studio 2012 Unit Test Report

Visual Studio 2012 and 2017 behavior for same website

Visual Studio 2012 Intellisence Icon - Icono desconocido

Cómo configurar Log4Net con ASP.NET (MVC incluido) C # en Visual Studio 2012 ~ ~

Detect if Visual C++ Redistributable for Visual Studio 2012 is installed

¿Cómo instalar XNA Game Studio en Visual Studio 2012?

Agregar .NET 4 a Visual Studio

Visual Studio 2012 won't let me debug Implementation of Interface

TF31003 при попытке подключиться к Visual Studio Team Services из VS 2012

Suivi du temps de compilation .cpp dans Visual Studio 2012

Uso de Visual Studio Express 2013 con TFS 2012

Référence circulaire C ++ Microsoft Visual Studio 2012

Retrouvez toutes les lignes commentées dans Visual Studio 2012

Visual Studio 2012 no tiene opciones de depuración

Cómo actualizar nuget con Visual Studio Express 2012

TOP Lista

  1. 1

    ¿Cómo ocultar la aplicación web de los robots de búsqueda? (ASP.NET)

  2. 2

    Pandas의 CSV 파일을 Pandas 데이터 프레임으로 가져 오기

  3. 3

    uitableview delete button image in iOS

  4. 4

    Manera correcta de agregar referencias al proyecto C # de modo que sean compatibles con el control de versiones

  5. 5

    Swift / Firebase : Facebook 사용자가 계정을 만들 때 Firebase 데이터베이스에 제대로 저장하려면 어떻게해야합니까?

  6. 6

    caída condicional de filas desde un marco de datos de pandas

  7. 7

    Link library in Visual Studio, why two different ways?

  8. 8

    Pagination class not getting applied in html

  9. 9

    Que signifie Decimal (-1)?

  10. 10

    UIButton textLabel with different fonts

  11. 11

    WPF pleine largeur DataGridColumn sur la largeur de DataGrid

  12. 12

    Opción de máquina virtual no reconocida 'MaxPermSize = 512m' cuando se ejecuta Zeppelin

  13. 13

    matplotlib로 그래프를 그리는 동안 커서 위치에서 날짜 / 시간을 볼 수 없습니다. "DateFormatter에서 x = 0 값을 찾았습니다"라는 오류가 발생합니다.

  14. 14

    ¿Es posible en Windows evitar que otras aplicaciones se enganchen en las DLL del sistema?

  15. 15

    Error de la base de datos de Android Firebase: Permiso denegado al depurar en un teléfono

  16. 16

    Pandas: suma filas de DataFrame para columnas dadas

  17. 17

    ggplot2: gráfico con líneas y puntos para problemas de leyenda de dos conjuntos de datos

  18. 18

    ¿Cómo especificar el puerto en el que se aloja una aplicación ASP.NET Core?

  19. 19

    Recherche de la position d'index d'une valeur dans r dataframe

  20. 20

    GPU를 사용하여 ffmpeg 필터의 처리 속도를 가속화하는 방법은 무엇입니까?

  21. 21

    nested observables executed one after the other after termination

CalienteEtiquetas

Archivo