Game becomes unplayable randomly at times?
Author |
Message |
The one they call Greed
|
Posted: Wed May 24, 2017 12:05 pm Post subject: Game becomes unplayable randomly at times? |
|
|
What is it you are trying to achieve?
I am making a RPG in the style of Fire Emblem, everything works well other then the occasional game breaking glitch or bug that just tends to happen at random times, I would like people to help find these errors and hopefully tell me how to fix them.
What is the problem you are having?
I do not know what is causing the bugs and glitches to happen, some of them only happen rarely like movement freezing up or buttons being unresponsive
Describe what you have tried to solve this problem
Rewriting various parts of the program and making things as efficient as I know how
Please specify what version of Turing you are using
4.1.1
Description: |
|
Download |
Filename: |
Fire_Emblem_5_24_17.t |
Filesize: |
23.68 KB |
Downloaded: |
150 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
The one they call Greed
|
Posted: Wed May 24, 2017 4:51 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
On certain monitors the screen size might be a little larger then what fully fits on the screen, sorry for the inconvenience.
|
|
|
|
|
|
Insectoid
|
Posted: Wed May 24, 2017 5:17 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
The best way to solve bugs like this is to find a way to reliably reproduce them. When a bug occurs, note what you were doing, and then do exactly that again. If the bug re-occurs, you're on the right track. Then look at the code that handles what you did and what the variables would look like at the time the bug occurred.
There's a good chance that you have a loop somewhere that is taking way too long to execute, so I'd be looking at that.
|
|
|
|
|
|
The one they call Greed
|
Posted: Wed May 24, 2017 5:38 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
The thing is, I never found any of them, the ones I found I fixed right away, my friend found all of the bugs, I wasn't paying exact attention to anything he did, so I have no clue to how he managed to achieve them.
|
|
|
|
|
|
Insectoid
|
Posted: Wed May 24, 2017 6:58 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
Maybe you should have paid attention then.
Paste your code here and I'll take a look and see if I can point you in the right direction. I don't want to download a file.
|
|
|
|
|
|
The one they call Greed
|
Posted: Wed May 24, 2017 7:55 pm Post subject: Re: Game becomes unplayable randomly at times? |
|
|
Turing: |
View.Set ("graphics:600,800")
%FSE IDEA#1: FIRE EMBLEM IN TURING
%DYLAN LAMOTHE 5/24/2017
%Range for movement allowed
var range, range2 : int := 3
var range3, range4 : int := 2
%Declaring fonts
var font1, font2 : int
%Fonts
font1 := Font.New ("Malaga:90:bold")
font2 := Font.New ("Malaga:20:bold")
%Used for movement tiles
var x, y, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8 : int
%Used to get copies of the location of the unit
var A, B, A2, B2, A3, B3, A4, B4 : int
%Used to determine AI movement and random variables
var ran : int
%Current Units
var unit1 : int
var unit2 : int
var unit3 : int
var unit4 : int
%Units life
var lunit1, lunit2, lunit3, lunit4 : boolean := true
%The menu
var menu : int
%Stats for units
var hp1, damage1, lvl1 : int
var hp2, damage2, lvl2 : int
var hp3, damage3, lvl3 : int
var hp4, damage4, lvl4 : int
%Turn switch
var turn1, turn2, turn3, turn4 : boolean := false
%Character movement
var chars : array char of boolean
%Declaring units and menu spot
unit1 := 18
unit2 := 175
unit3 := 7
unit4 := 162
menu := 1
hp1 := 20
hp2 := 20
hp3 := 30
hp4 := 30
damage1 := 4
damage2 := 4
damage3 := 3
damage4 := 3
ran := 0
%Text array
var text : array 1 .. 2 of string
text (1) := "Blue Attacked! Dealt " + intstr (damage1 + ran ) + " Damage"
text (2) := "Red Attacked! Dealt " + intstr (damage2 + ran ) + " Damage"
procedure tilesdrawn
%Draws out the entire board
Draw.Line (0, 50, 600, 50, black)
Draw.Line (0, 100, 600, 100, black)
Draw.Line (0, 150, 600, 150, black)
Draw.Line (0, 200, 600, 200, black)
Draw.Line (0, 250, 600, 250, black)
Draw.Line (0, 300, 600, 300, black)
Draw.Line (0, 350, 600, 350, black)
Draw.Line (0, 400, 600, 400, black)
Draw.Line (0, 450, 600, 450, black)
Draw.Line (0, 500, 600, 500, black)
Draw.Line (0, 550, 600, 550, black)
Draw.Line (0, 600, 600, 600, black)
Draw.Line (0, 650, 600, 650, black)
Draw.Line (0, 700, 600, 700, black)
Draw.Line (0, 750, 600, 750, black)
Draw.Line (0, 800, 600, 800, black)
Draw.Line (50, 0, 50, 800, black)
Draw.Line (100, 0, 100, 800, black)
Draw.Line (150, 0, 150, 800, black)
Draw.Line (200, 0, 200, 800, black)
Draw.Line (250, 0, 250, 800, black)
Draw.Line (300, 0, 300, 800, black)
Draw.Line (350, 0, 350, 800, black)
Draw.Line (400, 0, 400, 800, black)
Draw.Line (450, 0, 450, 800, black)
Draw.Line (500, 0, 500, 800, black)
Draw.Line (550, 0, 550, 800, black)
end tilesdrawn
procedure tutorial
%A tutorial and a little plot
Font.Draw ("Welcome to the world of Fire Emblem! In turing...", 40, 800, font2, black)
Font.Draw ("This is just a beta, not everything works..", 40, 760, font2, black)
Font.Draw ("This is V0.7:Core program made", 40, 720, font2, black)
Font.Draw ("INTRODUCTION", 40, 640, font2, black)
Font.Draw ("You are part of an army,", 40, 600, font2, black)
Font.Draw ("trying to defend against oncoming threats.", 40, 560, font2, black)
Font.Draw ("Command your army! Survive!", 40, 520, font2, black)
Font.Draw ("CONTROLS", 40, 480, font2, black)
Font.Draw ("Use the arrow keys to move", 40, 440, font2, black)
Font.Draw ("You only have 3 movements a turn", 40, 400, font2, black)
Font.Draw ("Press enter to end your turn", 40, 360, font2, black)
Font.Draw ("Press Tab to open your menu", 40, 320, font2, black)
Font.Draw ("Up and down arrows to navigate menu", 40, 280, font2, black)
Font.Draw ("Enter to confirm menu choice", 40, 240, font2, black)
Font.Draw ("Press any button to continue (Small Delay)", 40, 200, font2, black)
Font.Draw ("To battle, go next to enemy and press arrow...", 40, 160, font2, black)
Font.Draw ("In the direction they are.", 40, 120, font2, black)
Input.Pause ()
delay (500)
end tutorial
procedure tilesarea
%Shows the Unit on the tiles
if lunit1 = true then
for i : 1 .. 192
%192 is the amount of tiles
%Each tile has it so both the blue and red box can be atop of it.
if unit1 = i then
if i = 1 then
Draw.FillBox (10, 10, 40, 40, blue)
x := 10
y := 10
A := 1
B := 1
end if
if i >= 2 and i <= 12 then
%Forumla to get the units on tiles
Draw.FillBox (10 + ((i - 1) * 50), 10, 40 + ((i - 1) * 50), 40, blue)
x := 10 + ((i - 1) * 50)
y := 40
A := 1
B := i
end if
if i = 13 then
Draw.FillBox (10, 60, 40, 90, blue)
x := 10
y := 60
A := 2
B := 1
end if
if i >= 14 and i <= 24 then
Draw.FillBox (10 + ((i - 13) * 50), 60, 40 + ((i - 13) * 50), 90, blue)
x := 10 + ((i - 13) * 50)
y := 60
A := 2
B := i - 12
end if
if i = 25 then
Draw.FillBox (10, 110, 40, 140, blue)
x := 10
y := 110
A := 3
B := 1
end if
if i >= 26 and i <= 36 then
Draw.FillBox (10 + ((i - 25) * 50), 110, 40 + ((i - 25) * 50), 140, blue)
x := 10 + ((i - 25) * 50)
y := 110
A := 3
B := i - 24
end if
if i = 37 then
Draw.FillBox (10, 160, 40, 190, blue)
x := 10
y := 160
A := 4
B := 1
end if
if i >= 38 and i <= 48 then
Draw.FillBox (10 + ((i - 37) * 50), 160, 40 + ((i - 37) * 50), 190, blue)
x := 10 + ((i - 37) * 50)
y := 160
A := 4
B := i - 36
end if
if i = 49 then
Draw.FillBox (10, 210, 40, 240, blue)
x := 10
y := 210
A := 5
B := 1
end if
if i >= 50 and i <= 60 then
Draw.FillBox (10 + ((i - 49) * 50), 210, 40 + ((i - 49) * 50), 240, blue)
x := 10 + ((i - 49) * 50)
y := 210
A := 5
B := i - 48
end if
if i = 61 then
Draw.FillBox (10, 260, 40, 290, blue)
x := 10
y := 260
A := 6
B := 1
end if
if i >= 62 and i <= 72 then
Draw.FillBox (10 + ((i - 61) * 50), 260, 40 + ((i - 61) * 50), 290, blue)
x := 10 + ((i - 61) * 50)
y := 260
A := 6
B := i - 60
end if
if i = 73 then
Draw.FillBox (10, 310, 40, 340, blue)
x := 10
y := 310
A := 7
B := 1
end if
if i >= 74 and i <= 84 then
Draw.FillBox (10 + ((i - 73) * 50), 310, 40 + ((i - 73) * 50), 340, blue)
x := 10 + ((i - 73) * 50)
y := 310
A := 7
B := i - 72
end if
if i = 85 then
Draw.FillBox (10, 360, 40, 390, blue)
x := 10
y := 360
A := 8
B := 1
end if
if i >= 86 and i <= 96 then
Draw.FillBox (10 + ((i - 85) * 50), 360, 40 + ((i - 85) * 50), 390, blue)
x := 10 + ((i - 85) * 50)
y := 360
A := 8
B := i - 84
end if
if i = 97 then
Draw.FillBox (10, 410, 40, 440, blue)
x := 10
y := 410
A := 9
B := 1
end if
if i >= 98 and i <= 108 then
Draw.FillBox (10 + ((i - 97) * 50), 410, 40 + ((i - 97) * 50), 440, blue)
x := 10 + ((i - 97) * 50)
y := 410
A := 9
B := i - 96
end if
if i = 109 then
Draw.FillBox (10, 460, 40, 490, blue)
x := 10
y := 460
A := 10
B := 1
end if
if i >= 110 and i <= 120 then
Draw.FillBox (10 + ((i - 109) * 50), 460, 40 + ((i - 109) * 50), 490, blue)
x := 10 + ((i - 109) * 50)
y := 460
A := 10
B := i - 108
end if
if i = 121 then
Draw.FillBox (10, 510, 40, 540, blue)
x := 10
y := 510
A := 11
B := 1
end if
if i >= 122 and i <= 132 then
Draw.FillBox (10 + ((i - 121) * 50), 510, 40 + ((i - 121) * 50), 540, blue)
x := 10 + ((i - 121) * 50)
y := 510
A := 11
B := i - 120
end if
if i = 133 then
Draw.FillBox (10, 560, 40, 590, blue)
x := 10
y := 560
A := 12
B := 1
end if
if i >= 134 and i <= 144 then
Draw.FillBox (10 + ((i - 133) * 50), 560, 40 + ((i - 133) * 50), 590, blue)
x := 10 + ((i - 133) * 50)
y := 560
A := 12
B := i - 132
end if
if i = 145 then
Draw.FillBox (10, 610, 40, 640, blue)
x := 10
y := 610
A := 13
B := 1
end if
if i >= 146 and i <= 156 then
Draw.FillBox (10 + ((i - 145) * 50), 610, 40 + ((i - 145) * 50), 640, blue)
x := 10 + ((i - 145) * 50)
y := 610
A := 13
B := i - 144
end if
if i = 157 then
Draw.FillBox (10, 660, 40, 690, blue)
x := 10
y := 660
A := 14
B := 1
end if
if i >= 158 and i <= 168 then
Draw.FillBox (10 + ((i - 157) * 50), 660, 40 + ((i - 157) * 50), 690, blue)
x := 10 + ((i - 157) * 50)
y := 660
A := 14
B := i - 156
end if
if i = 169 then
Draw.FillBox (10, 710, 40, 740, blue)
x := 10
y := 710
A := 15
B := 1
end if
if i >= 170 and i <= 180 then
Draw.FillBox (10 + ((i - 169) * 50), 710, 40 + ((i - 169) * 50), 740, blue)
x := 10 + ((i - 169) * 50)
y := 710
A := 15
B := i - 168
end if
if i = 181 then
Draw.FillBox (10, 760, 40, 790, blue)
x := 10
y := 760
A := 16
B := 1
end if
if i >= 182 and i <= 192 then
Draw.FillBox (10 + ((i - 181) * 50), 760, 40 + ((i - 181) * 50), 790, blue)
x := 10 + ((i - 181) * 50)
y := 760
A := 16
B := i - 180
end if
end if
end for
end if
%Red unit
if lunit2 = true then
for i : 1 .. 192
if unit2 = i then
if i = 1 then
Draw.FillBox (10, 10, 40, 40, red)
x3 := 10
y3 := 10
A2 := 1
B2 := 1
end if
if i >= 2 and i <= 12 then
Draw.FillBox (10 + ((i - 1) * 50), 10, 40 + ((i - 1) * 50), 40, red)
x3 := 10 + ((i - 1) * 50)
y3 := 40
A2 := 1
B2 := i
end if
if i = 13 then
Draw.FillBox (10, 60, 40, 90, red)
x3 := 10
y3 := 60
A2 := 2
B2 := 1
end if
if i >= 14 and i <= 24 then
Draw.FillBox (10 + ((i - 13) * 50), 60, 40 + ((i - 13) * 50), 90, red)
x3 := 10 + ((i - 13) * 50)
y3 := 60
A2 := 2
B2 := i - 12
end if
if i = 25 then
Draw.FillBox (10, 110, 40, 140, red)
x3 := 10
y3 := 110
A2 := 3
B2 := 1
end if
if i >= 26 and i <= 36 then
Draw.FillBox (10 + ((i - 25) * 50), 110, 40 + ((i - 25) * 50), 140, red)
x3 := 10 + ((i - 25) * 50)
y3 := 110
A2 := 3
B2 := i - 24
end if
if i = 37 then
Draw.FillBox (10, 160, 40, 190, red)
x3 := 10
y3 := 160
A2 := 4
B2 := 1
end if
if i >= 38 and i <= 48 then
Draw.FillBox (10 + ((i - 37) * 50), 160, 40 + ((i - 37) * 50), 190, red)
x3 := 10 + ((i - 37) * 50)
y3 := 160
A2 := 4
B2 := i - 36
end if
if i = 49 then
Draw.FillBox (10, 210, 40, 240, red)
x3 := 10
y3 := 210
A2 := 5
B2 := 1
end if
if i >= 50 and i <= 60 then
Draw.FillBox (10 + ((i - 49) * 50), 210, 40 + ((i - 49) * 50), 240, red)
x3 := 10 + ((i - 49) * 50)
y3 := 210
A2 := 5
B2 := i - 48
end if
if i = 61 then
Draw.FillBox (10, 260, 40, 290, red)
x3 := 10
y3 := 260
A2 := 6
B2 := 1
end if
if i >= 62 and i <= 72 then
Draw.FillBox (10 + ((i - 61) * 50), 260, 40 + ((i - 61) * 50), 290, red)
x3 := 10 + ((i - 61) * 50)
y3 := 260
A2 := 6
B2 := i - 60
end if
if i = 73 then
Draw.FillBox (10, 310, 40, 340, red)
x3 := 10
y3 := 310
A2 := 7
B2 := 1
end if
if i >= 74 and i <= 84 then
Draw.FillBox (10 + ((i - 73) * 50), 310, 40 + ((i - 73) * 50), 340, red)
x3 := 10 + ((i - 73) * 50)
y3 := 310
A2 := 7
B2 := i - 72
end if
if i = 85 then
Draw.FillBox (10, 360, 40, 390, red)
x3 := 10
y3 := 360
A2 := 8
B2 := 1
end if
if i >= 86 and i <= 96 then
Draw.FillBox (10 + ((i - 85) * 50), 360, 40 + ((i - 85) * 50), 390, red)
x3 := 10 + ((i - 85) * 50)
y3 := 360
A2 := 8
B2 := i - 84
end if
if i = 97 then
Draw.FillBox (10, 410, 40, 440, red)
x3 := 10
y3 := 410
A2 := 9
B2 := 1
end if
if i >= 98 and i <= 108 then
Draw.FillBox (10 + ((i - 97) * 50), 410, 40 + ((i - 97) * 50), 440, red)
x3 := 10 + ((i - 97) * 50)
y3 := 410
A2 := 9
B2 := i - 96
end if
if i = 109 then
Draw.FillBox (10, 460, 40, 490, red)
x3 := 10
y3 := 460
A2 := 10
B2 := 1
end if
if i >= 110 and i <= 120 then
Draw.FillBox (10 + ((i - 109) * 50), 460, 40 + ((i - 109) * 50), 490, red)
x3 := 10 + ((i - 109) * 50)
y3 := 460
A2 := 10
B2 := i - 108
end if
if i = 121 then
Draw.FillBox (10, 510, 40, 540, red)
x3 := 10
y3 := 510
A2 := 11
B2 := 1
end if
if i >= 122 and i <= 132 then
Draw.FillBox (10 + ((i - 121) * 50), 510, 40 + ((i - 121) * 50), 540, red)
x3 := 10 + ((i - 121) * 50)
y3 := 510
A2 := 11
B2 := i - 120
end if
if i = 133 then
Draw.FillBox (10, 560, 40, 590, red)
x3 := 10
y3 := 560
A2 := 12
B2 := 1
end if
if i >= 134 and i <= 144 then
Draw.FillBox (10 + ((i - 133) * 50), 560, 40 + ((i - 133) * 50), 590, red)
x3 := 10 + ((i - 133) * 50)
y3 := 560
A2 := 12
B2 := i - 132
end if
if i = 145 then
Draw.FillBox (10, 610, 40, 640, red)
x3 := 10
y3 := 610
A2 := 13
B2 := 1
end if
if i >= 146 and i <= 156 then
Draw.FillBox (10 + ((i - 145) * 50), 610, 40 + ((i - 145) * 50), 640, red)
x3 := 10 + ((i - 145) * 50)
y3 := 610
A2 := 13
B2 := i - 144
end if
if i = 157 then
Draw.FillBox (10, 660, 40, 690, red)
x3 := 10
y3 := 660
A2 := 14
B2 := 1
end if
if i >= 158 and i <= 168 then
Draw.FillBox (10 + ((i - 157) * 50), 660, 40 + ((i - 157) * 50), 690, red)
x3 := 10 + ((i - 157) * 50)
y3 := 660
A2 := 14
B2 := i - 156
end if
if i = 169 then
Draw.FillBox (10, 710, 40, 740, red)
x3 := 10
y3 := 710
A2 := 15
B2 := 1
end if
if i >= 170 and i <= 180 then
Draw.FillBox (10 + ((i - 169) * 50), 710, 40 + ((i - 169) * 50), 740, red)
x3 := 10 + ((i - 169) * 50)
y3 := 710
A2 := 15
B2 := i - 168
end if
if i = 181 then
Draw.FillBox (10, 760, 40, 790, red)
x3 := 10
y3 := 760
A2 := 16
B2 := 1
end if
if i >= 182 and i <= 192 then
Draw.FillBox (10 + ((i - 181) * 50), 760, 40 + ((i - 181) * 50), 790, red)
x3 := 10 + ((i - 181) * 50)
y3 := 760
A2 := 16
B2 := i - 180
end if
end if
end for
end if
end tilesarea
procedure greentiles
%Shows movement for blue unit
if lunit1 = true then
if turn1 = true then
Draw.FillBox (x2 - 160, y2 - 10, x2 + 190, y2 + 40, green)
Draw.FillBox (x2 - 110, y2 - 60, x2 + 140, y2 + 90, green)
Draw.FillBox (x2 - 60, y2 - 110, x2 + 90, y2 + 140, green)
Draw.FillBox (x2 - 10, y2 - 160, x2 + 40, y2 + 190, green)
end if
end if
%Shows movement for red unit
if lunit2 = true then
if turn2 = true then
Draw.FillBox (x4 - 160, y4 - 10, x4 + 190, y4 + 40, 12)
Draw.FillBox (x4 - 110, y4 - 60, x4 + 140, y4 + 90, 12)
Draw.FillBox (x4 - 60, y4 - 110, x4 + 90, y4 + 140, 12)
Draw.FillBox (x4 - 10, y4 - 160, x4 + 40, y4 + 190, 12)
end if
end if
end greentiles
procedure actions
%The menu to access the different features
loop
Input.KeyDown (chars )
if chars (KEY_DOWN_ARROW) then
menu := menu + 1
delay (200)
cls
if menu = 4 then
menu := 1
end if
elsif chars (KEY_UP_ARROW) then
menu := menu - 1
delay (200)
cls
if menu = 0 then
menu := 3
end if
end if
if chars (KEY_ENTER ) then
if menu = 3 then
exit
end if
if menu = 2 then
cls
tutorial
cls
end if
end if
Font.Draw (">", 35, 340 - (menu * 30), font2, black)
Font.Draw ("Test", 50, 310, font2, black)
Font.Draw ("Open the tutorial", 50, 280, font2, black)
Font.Draw ("Exit Menu", 50, 250, font2, black)
end loop
end actions
procedure battle
%The battle phase
cls
Font.Draw ("Blue HP:", 30, 760, font2, black)
Font.Draw (intstr (hp1 ), 160, 760, font2, black)
Font.Draw ("Red HP:", 420, 760, font2, black)
Font.Draw (intstr (hp2 ), 540, 760, font2, black)
delay (2000)
if turn1 = true then
randint (ran, 1, 4)
text (1) := "Blue Attacked! Dealt " + intstr (damage1 + ran ) + " Damage"
hp2 := hp2 - (ran + damage1 )
if hp2 <= 0 then
hp2 := 0
lunit2 := false
end if
Font.Draw (text (1), 30, 300, font2, black)
delay (2000)
cls
Font.Draw ("Blue HP:", 30, 760, font2, black)
Font.Draw (intstr (hp1 ), 160, 760, font2, black)
Font.Draw ("Red HP:", 420, 760, font2, black)
Font.Draw (intstr (hp2 ), 540, 760, font2, black)
elsif turn2 = true then
randint (ran, 1, 4)
text (2) := "Red Attacked! Dealt " + intstr (damage2 + ran ) + " Damage"
hp1 := hp1 - (ran + damage2 )
if hp1 <= 0 then
hp1 := 0
lunit1 := false
end if
Font.Draw (text (2), 30, 300, font2, black)
delay (2000)
cls
Font.Draw ("Blue HP:", 30, 760, font2, black)
Font.Draw (intstr (hp1 ), 160, 760, font2, black)
Font.Draw ("Red HP:", 420, 760, font2, black)
Font.Draw (intstr (hp2 ), 540, 760, font2, black)
end if
end battle
procedure enemyturn
%The enemy and it's movement
if lunit2 = true then
cls
greentiles
tilesdrawn
tilesarea
delay (200)
range2 := 3
loop
if unit2 - 12 = unit1 or unit2 + 12 = unit1 or unit2 - 1 = unit1 or unit2 + 1 = unit1 then
battle
delay (2000)
cls
greentiles
tilesdrawn
tilesarea
exit
end if
cls
greentiles
tilesdrawn
tilesarea
delay (200)
if range2 = 0 then
exit
end if
if A2 > A and B2 > B and B2 not= 12 and A2 not= 1 and range2 > 0 then
randint (ran, 1, 2)
if ran = 1 then
unit2 := unit2 - 12
range2 := range2 - 1
elsif ran = 2 then
unit2 := unit2 - 1
range2 := range2 - 1
end if
elsif A2 > A and B2 < B and B2 not= 1 and A2 not= 1 and range2 > 0 then
randint (ran, 1, 2)
if ran = 1 then
unit2 := unit2 - 12
range2 := range2 - 1
elsif ran = 2 then
unit2 := unit2 + 1
range2 := range2 - 1
end if
elsif A2 < A and B2 > B and B2 not= 12 and A2 not= 16 and range2 > 0 then
randint (ran, 1, 2)
if ran = 1 then
unit2 := unit2 + 12
range2 := range2 - 1
elsif ran = 2 then
unit2 := unit2 - 1
range2 := range2 - 1
end if
elsif A2 < A and B2 < B and B2 not= 1 and A2 not= 16 and range2 > 0 then
randint (ran, 1, 2)
if ran = 1 then
unit2 := unit2 + 12
range2 := range2 - 1
elsif ran = 2 then
unit2 := unit2 + 1
range2 := range2 - 1
end if
elsif A2 > A and B2 = B and A2 not= 1 and range2 > 0 then
unit2 := unit2 - 12
range2 := range2 - 1
elsif A2 < A and B2 = B and A2 not= 16 and range2 > 0 then
unit2 := unit2 + 12
range2 := range2 - 1
elsif A2 = A and B2 > B and B2 not= 12 and range2 > 0 then
unit2 := unit2 - 1
range2 := range2 - 1
elsif A2 = A and B2 < B and B2 not= 1 and range2 > 0 then
unit2 := unit2 + 1
range2 := range2 - 1
end if
end loop
end if
end enemyturn
%Opens up the main game
tutorial
tilesdrawn
tilesarea
x2 := x
y2 := y
x4 := x3
y4 := y3
cls
turn1 := true
greentiles
tilesdrawn
tilesarea
%The main controls and movement
loop
Input.KeyDown (chars )
if lunit1 = true then
if chars (KEY_RIGHT_ARROW) and unit1 mod 12 not= 0 and range >= 1 and unit1 + 1 not= unit2 then
unit1 := unit1 + 1
range := range - 1
cls
greentiles
tilesdrawn
tilesarea
delay (200)
end if
if chars (KEY_LEFT_ARROW) and unit1 mod 12 not= 1 and range >= 1 and unit1 - 1 not= unit2 then
unit1 := unit1 - 1
range := range - 1
cls
greentiles
tilesdrawn
tilesarea
delay (200)
end if
if chars (KEY_UP_ARROW) and unit1 >= 1 and unit1 <= 179 and range >= 1 and unit1 + 12 not= unit2 then
unit1 := unit1 + 12
range := range - 1
cls
greentiles
tilesdrawn
tilesarea
delay (200)
end if
if chars (KEY_DOWN_ARROW) and unit1 >= 13 and unit1 <= 192 and range >= 1 and unit1 - 12 not= unit2 then
unit1 := unit1 - 12
range := range - 1
cls
greentiles
tilesdrawn
tilesarea
delay (200)
end if
if chars (KEY_ENTER ) then
x2 := x
y2 := y
range := 3
Font.Draw ("Turn End", 50, 400, font1, 54)
delay (1000)
turn1 := false
turn2 := true
cls
x4 := x3
y4 := y3
enemyturn
delay (1000)
Font.Draw ("Turn End", 50, 400, font1, 112)
delay (1000)
turn1 := true
turn2 := false
cls
greentiles
tilesdrawn
tilesarea
delay (500)
end if
if chars (KEY_TAB ) then
cls
actions
cls
greentiles
tilesdrawn
tilesarea
delay (500)
end if
if chars (KEY_UP_ARROW) and unit1 + 12 = unit2 then
battle
delay (2000)
cls
greentiles
tilesdrawn
tilesarea
x2 := x
y2 := y
range := 3
Font.Draw ("Turn End", 50, 400, font1, 54)
delay (1000)
turn1 := false
turn2 := true
cls
x4 := x3
y4 := y3
enemyturn
delay (1000)
Font.Draw ("Turn End", 50, 400, font1, 112)
delay (1000)
turn1 := true
turn2 := false
cls
greentiles
tilesdrawn
tilesarea
delay (500)
end if
if chars (KEY_DOWN_ARROW) and unit1 - 12 = unit2 then
battle
delay (2000)
cls
greentiles
tilesdrawn
tilesarea
x2 := x
y2 := y
range := 3
Font.Draw ("Turn End", 50, 400, font1, 54)
delay (1000)
turn1 := false
turn2 := true
cls
x4 := x3
y4 := y3
enemyturn
delay (1000)
Font.Draw ("Turn End", 50, 400, font1, 112)
delay (1000)
turn1 := true
turn2 := false
cls
greentiles
tilesdrawn
tilesarea
delay (500)
end if
if chars (KEY_RIGHT_ARROW) and unit1 + 1 = unit2 then
battle
delay (2000)
cls
greentiles
tilesdrawn
tilesarea
x2 := x
y2 := y
range := 3
Font.Draw ("Turn End", 50, 400, font1, 54)
delay (1000)
turn1 := false
turn2 := true
cls
x4 := x3
y4 := y3
enemyturn
delay (1000)
Font.Draw ("Turn End", 50, 400, font1, 112)
delay (1000)
turn1 := true
turn2 := false
cls
greentiles
tilesdrawn
tilesarea
delay (500)
end if
if chars (KEY_LEFT_ARROW) and unit1 - 1 = unit2 then
battle
delay (2000)
cls
greentiles
tilesdrawn
tilesarea
x2 := x
y2 := y
range := 3
Font.Draw ("Turn End", 50, 400, font1, 54)
delay (1000)
turn1 := false
turn2 := true
cls
x4 := x3
y4 := y3
enemyturn
delay (1000)
Font.Draw ("Turn End", 50, 400, font1, 112)
delay (1000)
turn1 := true
turn2 := false
cls
greentiles
tilesdrawn
tilesarea
delay (500)
end if
end if
if lunit1 = false then
greentiles
tilesdrawn
tilesarea
delay (2000)
exit
end if
if lunit2 = false then
greentiles
tilesdrawn
tilesarea
delay (2000)
exit
end if
end loop
if lunit1 = false then
Font.Draw ("YOU DIED", 10, 400, font1, 112)
elsif lunit2 = false then
Font.Draw ("VICTORY", 50, 400, font1, 54)
end if
|
Its a pretty lengthy file
|
|
|
|
|
|
The one they call Greed
|
Posted: Wed May 24, 2017 7:56 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
Honestly, I don't even know if I managed to fix everything.
|
|
|
|
|
|
Insectoid
|
Posted: Wed May 24, 2017 8:02 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
Okay, now when does it freeze up? Is it totally random? Does it only happen in one phase? Can you reproduce the bug?
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
The one they call Greed
|
Posted: Wed May 24, 2017 8:22 pm Post subject: RE:Game becomes unplayable randomly at times? |
|
|
It is totally random in the movement phase, I have seen it happen twice but no clue on how it was done or how to reproduce it.
|
|
|
|
|
|
Insectoid
|
Posted: Thu May 25, 2017 9:19 am Post subject: RE:Game becomes unplayable randomly at times? |
|
|
What happens if you hold multiple arrow keys at the same time during the movement phase?
|
|
|
|
|
|
The one they call Greed
|
Posted: Thu May 25, 2017 10:23 am Post subject: RE:Game becomes unplayable randomly at times? |
|
|
Because it's set to an if command using elsif, it will just do one then the other until you run out of actions.
|
|
|
|
|
|
Insectoid
|
Posted: Thu May 25, 2017 10:43 am Post subject: RE:Game becomes unplayable randomly at times? |
|
|
But you aren't using elsif. Those are all separate if statements, each with their own delays, and each of which calls big draw procedures. If you press both left and right at the same time, it will cls, then draw everything, then delay, then cls, then draw everything, then delay. Some of those delays are massive. When you delay, your program pauses. Nothing can happen during that time. Keypresses will not register. Furthermore, drawing in Turing is very slow. Not as slow as a delay, but still slow. Unnecessarily re-drawing everything several times is going to slow you down a lot. This might not be the cause of your bug, but it also might be, and it's just poor programming.
|
|
|
|
|
|
The one they call Greed
|
Posted: Thu May 25, 2017 11:19 am Post subject: RE:Game becomes unplayable randomly at times? |
|
|
Sorry for the mistake, I forgot the one posted was the one at my house,at my school I tweaked the if statements slightly, but the redrawing and clearing I have no idea how to make that more efficient and keep the effect I want it to have. Everywhere I use the program, the re-drawing hasn't slowed down the program and the delays are used to prevent that "double arrow" thing you said before. Thank you for assisting with what you can.
|
|
|
|
|
|
The one they call Greed
|
Posted: Fri May 26, 2017 11:07 am Post subject: RE:Game becomes unplayable randomly at times? |
|
|
Fixed up the bugs and glitches that I have noticed, it's working well now.
|
|
|
|
|
|
|
|