need help with prog plz
Author |
Message |
venom
|
Posted: Thu Oct 05, 2006 12:06 pm Post subject: need help with prog plz |
|
|
im a new member here and a noob when it comes to certain thing in turing
my teacher is of no help and i cant find a thread with my problem
im trying to make a survival game on turing but i cant get the main character to move when the boss attacks, i've tried all that i can think of >.>''
code: |
colourback (black) %background current
View.Set ("offscreenonly")
%--------------------------------------------------------------------------
var picID, picID2, picIDflip, picIDboss : int
var x : int := 0
var y : int := 0
var chars : array char of boolean
var pts : int := 1
var key : string (1)
var i: int
%--------------------------------------------------------------------------
proc intro
randint (i, 1, 255)
drawfillbox (0, 0, maxx, maxy, i)
end intro
%-------------------------------------------------------------------------
proc gamepiece
drawline (0, 10, 20, 50, red) %... main body
drawline (40, 10, 20, 50, red) %... main body
drawline (0, 10, 20, 20, red) %... main body
drawline (40, 10, 20, 20, red) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end gamepiece
%--------------------------------------------------------------------------
proc boss
drawfillbox (5, 5, 10, 50, yellow) %...cannon
drawfillbox (30, 5, 35, 50, yellow) %...cannon
drawline (0, 10, 20, 50, purple) %... main body
drawline (40, 10, 20, 50, purple) %... main body
drawline (0, 10, 20, 20, purple) %... main body
drawline (40, 10, 20, 20, purple) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end boss
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
intro
getch (key)
cls
gamepiece
picID := Pic.New (0, 8, 42, 50)
boss
picID2 := Pic.New (0, 8, 42, 221)
cls
picIDflip := Pic.Flip (picID2)
Pic.Draw (picIDflip, 20, 20, picMerge)
cls
picID2 := Pic.Scale (picIDflip, 3 * 50, 3 * 150)
Pic.Draw (picID2, (1 - 1) * maxx div 3 + 300, (1 - 1) * maxy div 3 + 120, picMerge)
%-----------------------------main game------------------------------------
loop
Pic.Draw (picID, x, y, picMerge)
delay (5)
View.Update
cls %... background procedure for the program
Pic.Draw (picID2, 235, 10, picMerge)
locate (1, 1)
Text.Color (white)
put "points! ", pts ..
pts := pts + 2
%--------------------------------------------------------------------------
Input.KeyDown (chars)
locate (1, 1)
if chars (KEY_UP_ARROW) then
y := y + 5
else
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
else
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
else
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
else
end if
%--------------------------------------------------------------------------
%prevents offscreen
if x < 0 then
x := x + 5
end if
if x > 595 then
x := x - 5
end if
if y < 0 then
y := y + 5
end if
if y > 300 then
y := y - 5
end if
%--------------------------------------------------------------------------
for h : 1 .. 800 %.. boss attack
Draw.ThickLine (350, 360, 315 + h, 0, 20, white)%.. boss attack
Draw.ThickLine (260, 360, 295 - h, 0, 20, white)%.. boss attack
View.Update
end for%.. boss attack end
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
neufelni
|
Posted: Thu Oct 05, 2006 5:01 pm Post subject: (No subject) |
|
|
The problem is not that you can't get him to move. He is moving but you can't see it because you draw stuff over top of him. You need to get rid of your Pic.Draw at the beginning of your loop, and put it in your for loop right before the View.Update.
code: | for h : 1 .. 800 %.. boss attack
Draw.ThickLine (350, 360, 315 + h, 0, 20, white)%.. boss attack
Draw.ThickLine (260, 360, 295 - h, 0, 20, white)%.. boss attack
Pic.Draw (picID, x, y, picMerge)
View.Update
end for%.. boss attack end |
|
|
|
|
|
|
venom
|
Posted: Tue Oct 10, 2006 12:06 pm Post subject: (No subject) |
|
|
thanks for that help with the movement but its running blocky when the boss attacks my game piece wont move untill it ends
im not absolutly sure how to have the boss attack seprate from the gamepiece's movement
i most likely have to use a flexiable array but im having troubles understanding how it work and the tutorial on it just confuses the hell out of me
am i a failure at turing |
|
|
|
|
|
neufelni
|
Posted: Tue Oct 10, 2006 3:46 pm Post subject: (No subject) |
|
|
You don't need to use flexible arrays. All you need to do is get rid of the for loop at the bottom and put the stuff that was in it into the main loop. So the first thing that you need to do is declare a variable h and set it to 1. Then you make h increase by one each time that you go through the loop. Just replace your for loop with this.
code: | Draw.ThickLine (350, 360, 315 + h, 0, 20, white) %.. boss attack
Draw.ThickLine (260, 360, 295 - h, 0, 20, white) %.. boss attack
h += 1
if h = 800 then
h := 2
end if
Pic.Draw (picID, x, y, picMerge)
View.Update |
This will do the same thing as your for loop but it is now part of the main loop. |
|
|
|
|
|
venom
|
Posted: Wed Oct 25, 2006 1:26 pm Post subject: (No subject) |
|
|
so far ive gotten the first attack to work im currently setting up a file saving addition to the programing as well as a collision so that you can actually can die but im trying to get the atk proc to run more than once so that it looks as if its streaming out but... i get the flickering and im not getting what im looking for
if you've played a game called gradius im trying to get the look af a boss fight im hoping to add parabolas to the mix
but i doubt that we will even cross that lesson >.>
code: |
%background current
colourback (black)
View.Set ("offscreenonly")
%--------------------------------------------------------------------------
var picID, picID2, picIDflip, picIDboss : int
var x : int := 0 %moves the character,sets the screen limits
var y : int := 0 %%moves the character,sets the screen limits
var chars : array char of boolean %character movement
var pts : int := 1 %point system
var key : string (1) %moves the intro to the main game
var i : int %allows the intro to run in random colours
var h, g : int := 1
var ID : array 1 .. 10 of string %sets the ammount of names to ten
var score : array 1 .. 10 of int %sets the ammount of names to ten
var s := 0
var num : int %checks first value
var d : int
%--------------------------------------------------------------------------
proc intro
randint (i, 1, 255) % random number from 1 to 255
drawfillbox (0, 0, maxx, maxy, i) % draws a box in a random colour
Text.Color (white)
locate (15, 30)
put "Space evasion!" ..
end intro
% proc highscore
%
% open : d, "high_score.txt", get % accesses the data file
% assert d > 0 %checks if the file is made
% %-----------------------------------------------------------
% %checks data file
% get : d, num
%
% if num = 0 then
% put "the file is currently empty, please continue the game."
% else
%
% put "file not empty reading the data."
% delay (500)
% open : d, "high_score.txt", get
% assert d > 0
% loop %repeats till data is read
% s := s + 1 %adds up the number of players
% get : d, score (s) %retrived score
% put score (s) %display
% get : d, ID (s) %retrives names
% put ID (s) %display
%
% exit when eof (d)
% end loop
% end if
%
% close : d
% delay (3000)
% cls
%
% loop
% s := s + 1 %give the data a number
% put "Please enter your name."
% put "When finished press q to exit."
% get ID (s) %gets the players name
% exit when ID (s) = "q"
% put "Please enter your score."
% get score (s) %gets the players score
% cls
% end loop
% s := s - 1
% %saves data when person quits
%
% open : d, "high_score.txt", put % accesses the data file
% assert d > 0
% for n : 1 .. s %prepeats for the ammount of people
% %places the data into the txt file
% put : d, score (s) %places the data into the txt file
% put : d, ID (s)
% end for
%
% close : d
% cls
% end highscore
%-------------------------------------------------------------------------
proc gamepiece
drawline (0, 10, 20, 50, red) %... main body
drawline (40, 10, 20, 50, red) %... main body
drawline (0, 10, 20, 20, red) %... main body
drawline (40, 10, 20, 20, red) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end gamepiece
%--------------------------------------------------------------------------
proc boss
drawfillbox (5, 5, 10, 50, yellow) %...cannon
drawfillbox (30, 5, 35, 50, yellow) %...cannon
drawline (0, 10, 20, 50, purple) %... main body
drawline (40, 10, 20, 50, purple) %... main body
drawline (0, 10, 20, 20, purple) %... main body
drawline (40, 10, 20, 20, purple) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end boss
%--------------------------------------------------------------------------
proc atk
Draw.FillOval (350 - h, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260 + h, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (350 + h, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260 - h, 360 - h, 15, 20, white) %.. boss attack
h += 1
g += 1
if h = 400 then
h := 2
end if
if g = 20 then
g := 2
end if
Pic.Draw (picID, x, y, picMerge)
View.Update
cls
end atk
proc atk2
Draw.FillOval (350 - h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260 + h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (350 + h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260 - h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
h += 1
g += 1
if h = 400 then
h := 2
end if
if g = 20 then
g := 2
end if
Pic.Draw (picID, x, y, picMerge)
View.Update
cls
end atk2
%--------------------------------------------------------------------------
%highscore
intro % intro screen
getch (key) % move onto the main game
cls
gamepiece % draws the character
picID := Pic.New (0, 8, 42, 50) % allows the character to move
boss
picID2 := Pic.New (0, 8, 42, 221) % draws unaltered version of boss
cls
picIDflip := Pic.Flip (picID2) % flips the boss pic
Pic.Draw (picIDflip, 20, 20, picMerge)
cls
picID2 := Pic.Scale (picIDflip, 3 * 50, 3 * 150)
Pic.Draw (picID2, (1 - 1) * maxx div 3 + 300, (1 - 1) * maxy div 3 + 120, picMerge) % rescales the size of the image
%-----------------------------main game------------------------------------
loop
%... background procedure for the program
Pic.Draw (picID2, 235, 10, picMerge)
locate (1, 1) % places in top left corner
Text.Color (white) % point text is in white
put "points! ", pts .. % points are time based
pts := pts + 2
%--------------------------------------------------------------------------
Input.KeyDown (chars)
locate (1, 1)
if chars (KEY_UP_ARROW) then % move character up
y := y + 5
else
end if
if chars (KEY_RIGHT_ARROW) then % move character right
x := x + 5
else
end if
if chars (KEY_LEFT_ARROW) then % move character left
x := x - 5
else
end if
if chars (KEY_DOWN_ARROW) then % move character dowm
y := y - 5
else
end if
%--------------------------------------------------------------------------
%prevents offscreen
if x < 0 then
x := x + 5
end if
if x > 595 then
x := x - 5
end if
if y < 0 then
y := y + 5
end if
if y > 300 then
y := y - 5
end if
atk
atk2
%--------------------------------------------------------------------------
end loop
|
|
|
|
|
|
|
neufelni
|
Posted: Wed Oct 25, 2006 4:05 pm Post subject: (No subject) |
|
|
Taking care of the flickering is easy. You need to get rid of all the View.Updates and cls in your procedures and just add a View.Update and a cls to the very end of your main loop. |
|
|
|
|
|
venom
|
Posted: Fri Nov 10, 2006 2:31 pm Post subject: (No subject) |
|
|
code: |
%background current
View.Set ("offscreenonly")
%--------------------------------------------------------------------------
var picID, picID2, picIDflip, picIDboss : int
var x : int := 0 %moves the character,sets the screen limits
var y : int := 0 %%moves the character,sets the screen limits
var chars : array char of boolean %character movement
var pts : int := 1 %point system
var key : string (1) %moves the intro to the main game
var i : int %allows the intro to run in random colours
var h, g : int := 1
var ID : array 1 .. 10 of string %sets the ammount of names to ten
var score : array 1 .. 10 of int %sets the ammount of scores to ten
var n := 0
var num : int %checks first value
var dd : int
var d : int := 0
%--------------------------------------------------------------------------
proc intro
randint (i, 1, 255) % random number from 1 to 255
drawfillbox (0, 0, maxx, maxy, i) % draws a box in a random colour
Text.Color (black)
locate (15, 30)
put "Space evasion!" ..
end intro
proc highscore
open : dd, "high_score.txt", get % accesses the data file
assert dd > 0 %checks if the file is made
%-----------------------------------------------------------
%checks data file
get : dd, num
close : dd
if num = 0 then
put "the file is currently empty, please continue the game."
else
put "file not empty reading the data."
delay (500)
open : dd, "high_score.txt", get
assert dd > 0
loop
n := n + 1 %repeats till data is read
%adds up the number of players
get : dd, score (n) %retrived score
put score (n) %display
View.Update
get : dd, ID (n) %retrives names
put ID (n) %display
View.Update
exit when eof (dd)
end loop
close : dd
end if
put "the num is players is ", n
delay (3000)
end highscore
proc highscore2
View.Update
Text.Color (white)
%give the data a number
locate (12, 30)
put "Please enter your name."
locate (13, 30)
put "When finished press q to exit."
View.Update
locate (14, 30)
d := d + 1
get ID (d)
View.Update %gets the players name
score (d) := pts %gets players score
cls
%saves data when person quits
open : dd, "high_score.txt", put % accesses the data file
assert dd > 0 %stream number
for c : 1 .. d %prepeats for the ammount of people
put : dd, score (c) %places the data into the txt file
put : dd, ID (c) % places data into the txt file
end for
close : dd %ends the file saving
cls
View.Update
end highscore2
%-------------------------------------------------------------------------
proc gamepiece
drawline (0, 10, 20, 50, red) %... main body
drawline (40, 10, 20, 50, red) %... main body
drawline (0, 10, 20, 20, red) %... main body
drawline (40, 10, 20, 20, red) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end gamepiece
%--------------------------------------------------------------------------
proc boss
drawfillbox (5, 5, 10, 50, yellow) %...cannon
drawfillbox (30, 5, 35, 50, yellow) %...cannon
drawline (0, 10, 20, 50, purple) %... main body
drawline (40, 10, 20, 50, purple) %... main body
drawline (0, 10, 20, 20, purple) %... main body
drawline (40, 10, 20, 20, purple) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end boss
%--------------------------------------------------------------------------
proc atk
Draw.FillOval (350, 360 - h, 15, 15, white) %.. boss attack
Draw.FillOval (260, 360 - h, 15, 15, white) %.. boss attack
h += 1
g += 1
if h = 400 then
h := 2
end if
if g = 20 then
g := 2
end if
Pic.Draw (picID, x, y, picMerge)
View.Update
cls
end atk
proc atk2
end atk2
%--------------------------------------------------------------------------
highscore
cls
intro
View.Update
% intro screen
getch (key) % move onto the main game
cls
gamepiece % draws the character
picID := Pic.New (0, 8, 42, 50) % allows the character to move
boss
picID2 := Pic.New (0, 8, 42, 221) % draws unaltered version of boss
cls
picIDflip := Pic.Flip (picID2) % flips the boss pic
Pic.Draw (picIDflip, 20, 20, picMerge)
cls
picID2 := Pic.Scale (picIDflip, 3 * 50, 3 * 150)
Pic.Draw (picID2, (1 - 1) * maxx div 3 + 300, (1 - 1) * maxy div 3 + 120, picMerge) % rescales the size of the image
%-----------------------------main game------------------------------------
loop
colourback (black)
%... background procedure for the program
Pic.Draw (picID2, 235, 10, picMerge)
locate (1, 1) % places in top left corner
Text.Color (white) % point text is in white
put "points! ", pts .. % points are time based
pts := pts + 1
%--------------------------------------------------------------------------
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then % move character up
y := y + 5
else
end if
if chars (KEY_RIGHT_ARROW) then % move character right
x := x + 5
else
end if
if chars (KEY_LEFT_ARROW) then % move character left
x := x - 5
else
end if
if chars (KEY_DOWN_ARROW) then % move character dowm
y := y - 5
else
end if
%--------------------------------------------------------------------------
%prevents offscreen
if x < 0 then
x := x + 1
end if
if x > 595 then
x := x - 1
end if
if y < 0 then
y := y + 1
end if
if y > 300 then
y := y - 1
end if
if x > 210 and x < 140 and y > 155 and y < 125 then
break
end if
atk
Text.Colour (white)
locate (15, 10)
put "x", x
locate (17, 10)
put "y", y
if x >= 292 and y > 10 and x > 20 and y > 10 then
cls
View.Update
locate (10, 30)
Text.Colour (white)
put "game over"
View.Update
highscore2
break;
end if
colourback (black)
end loop
|
a new problem has plagued me again with file file saving portion of the program even my teacher cannot fix this, my program cannot save more than one name and i have tried many thing it worked once b4 but it broken down the next time through! |
|
|
|
|
|
jrblast
|
Posted: Fri Nov 10, 2006 5:52 pm Post subject: (No subject) |
|
|
change
code: | open : dd, "high_score.txt", put |
to
code: | open : dd, "high_score.txt", put,mod |
this will just add to the file instead of erasing everithing first |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|