SDL code working fine only on my computer



So i'm learning c++ and decided to try SDL out so I can get used to working with classes. The game is basically a space shooter game , so i wrote some code that permits the "shooting of bullets".The code works fine on my computer , the bullets travel from point X to point Y without a problem.When i tried to run the game on 2 different computers the "bullets" are very buggy (they disappear and reapper at random and such) .The rest of the game works fine. I tested the framerate on both computers and the fps is over 300

Does anyone know what causes this and how to solve it?


Here's some code (for the bullets) if you need it for some reason:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

 ///////////////////////////////////////FOR EVIL SHIPS////////////////////////////////////////////////

    //LOAD BULLET IF FREE

    if(bulletEnemyCooldown.getTicks() > bulletEnemyCooldownVar)
    {
        bulletEnemyCooldown.reset();

        for (int i = 0; i < kShips; i++)
        {
            if(!evilShip[i].getIfDead())
            {
                for(int j=0; j<99; j++)
                {
                    if (evilShip[i].getIfBulletFree(j))
                    {
                        evilShip[i].setKBullets(evilShip[i].getkBullets() + 1);
                        evilShip[i].setRectPos(evilShip[i].getPosX(),evilShip[i].getPosY(),j);
                        evilShip[i].setIfBulletFree(false,j);
                        break;
                    }
                }
            }
        }
    }

    //CHANGE BULLET POS IF SLOT OCC AND RENDER

    for (int i2 = 0; i2 <= kShips; i2++)
    {
        if(!evilShip[i2].getIfDead())
        {
            for(int j2 = 0; j2<evilShip[i2].getkBullets(); j2++)
            {
                if (evilShip[i2].getIfBulletFree(j2) == false)
                {
                    evilShip[i2].setBulletRectY( evilShip[i2].getBulletRectY(j2) + bulletS,j2);
                    enemy_bullet_texture.render(gRenderer, evilShip[i2].getBulletRectX(j2), evilShip[i2].getBulletRectY(j2));
                    evilShip[i2].setBulletDis(evilShip[i2].getBulletDis(j2) + bulletS,j2);
                }

            }
        }
    }

    //CHECK FOR ANY COLLISION AND FREE BULLET IF FOUND

    for (int i = 0; i < kShips; i++)
    {
        for (int j = 0; j < evilShip[i].getkBullets(); j++)
        {
            if(!evilShip[i].getIfDead())
            {
                if (checkCollision(evilShip[i].getBulletPosRect(j), mainShip.getmCollider()))
                {
                    evilShip[i].setIfBulletFree(true,j);
                    evilShip[i].setBulletDis(0,j);
                    evilShip[i].setKBullets( evilShip[i].getkBullets() - 1);
                    evilShip[i].setRectPos(0,0,j);

                    boolMainShipContact = true;

                    mainShip.curSetHP(mainShip.curGetHP() - evilShip[i].curGetATK());
                    kShipContact = i;

                    score -= rand()%(10 * currentLevel);
                }
            }

            // FREE BULLET IF FOUND OFF SCREEN

            if (evilShip[i].getBulletDis(j) > SCREEN_HEIGHT)
            {
                evilShip[i].setIfBulletFree(true,j);
                evilShip[i].setBulletDis(0,j);
                evilShip[i].setKBullets(evilShip[i].getkBullets() - 1);
            }

        }
    }

Topic archived. No new replies allowed.