"get" prompt. Can't see what is being typed with cursor.
Author |
Message |
tecnikal
|
Posted: Sat May 30, 2009 10:17 am Post subject: "get" prompt. Can't see what is being typed with cursor. |
|
|
What is it you are trying to achieve?
placing a "get" prompt and seeing what is being typed.
What is the problem you are having?
I have a get prompt BUT when i type, what is typed is not seen
Describe what you have tried to solve this problem
get rid of cls in places,changed up view update
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
import GUI % BUTTONS
% sets the ID of the window for closing it with "quit" procedure
var winID : int
winID := Window.Open ("graphics:700;520,nobuttonbar,position:center;center")
% ----------- Variable Set for Sprites -----------
% ########### PLAYER ONES UNITS ####################
%
var tank1 : int := Pic.FileNew ("tank1.bmp")
var mdtank1 : int := Pic.FileNew ("mdtank1.bmp")
%var gigatank1 : int := Pic.FileNew ("gigatank1.bmp")
var artillery1 : int := Pic.FileNew ("artillery1.bmp")
var infantry1 : int := Pic.FileNew ("infantry1.bmp")
var bazooka1 : int := Pic.FileNew ("bazooka1.bmp")
%
% ##################################################
% ################# PLAYER TWO UNITS ###############
var tank2 : int := Pic.FileNew("tank2.bmp")
var mdtank2 : int := Pic.FileNew ("mdtank2.bmp")
%var gigatank2 : int := Pic.FileNew ("gigatank2.bmp")
var artillery2 : int := Pic.FileNew ("artillery2.bmp")
var infantry2: int := Pic.FileNew ("infantry2.bmp")
var bazooka2: int := Pic.FileNew ("bazooka2.bmp")
% ##################################################
% UNIT STATS
% >>> TANK1 <<<
var tank1_health : int := 15
var tank1_min_hit : int := 6
var tank1_max_hit : int := 10
% >>> MID TANK1 <<<
var mdtank1_health : int := 20
var mdtank1_min_hit : int := 7
var mdtank1_max_hit : int := 13
% >>> ARTILLERY1 <<<
var artillery1_health : int := 20
var artillery1_min_hit : int := 11
var artillery1_max_hit : int := 17
% >>> INFANTRY1 <<<
var infantry1_health : int := 10
var infantry1_min_hit : int := 3
var infantry1_max_hit : int := 7
% >>> BAZOOKA1 <<<
var bazooka1_health : int := 10
var bazooka1_min_hit : int := 5
var bazooka1_max_hit : int := 8
% ########### PLAYER TWO UNITS #####################
% #
%var tank2 : int := Pic.FileNew ("tank2.bmp")% #
%var mid_tank2 : int := Pic.FileNew ("mdtank2.bmp")% #
%var gigatank2 : int := Pic.FileNew ("gigatank2.bmp")%#
%var artillery2 : int := Pic.FileNew ("artillery2.bmp")#
%var infantry2 : int := Pic.FileNew ("infantry2.bmp")%#
%var bazooka2 : int := Pic.FileNew ("bazooka2.bmp")% #
% #
% ##################################################
% _--------------------- SET VARS FOR MAP ---------------
var tiles : array 0 .. 21, 0 .. 21 of int
var level1 : int := Pic.FileNew ("map1111(black).bmp")
var FileName : string := "map.txt"
var FileNo : int
open : FileNo, FileName, get
for decreasing y : 21 .. 5 % for every y
for x : 0 .. 21 %for every x
get : FileNo, tiles (x, y ) %get the tile type at (x,y)
end for
end for
close (FileNo )
% ---------- DRAWS GRID FOR CURSOR ------------
proc reDraw
%sets the screen for the game to be loaded on.
View.Set ("graphics:660;660,nobuttonbar,position:center;center")
for x : 0 .. 21
for y : 5 .. 21
%if tiles (x, y) = 1 then
% drawbox (x * 30, y * 30, x * 30 + 30, y * 30 + 30, black) % the +30 is there because each tile is 30 by 30
%else
%drawbox (x * 30, y * 30, x * 30 + 30, y * 30 + 30, white)
% end if
end for
end for
end reDraw
% --------------------Gameplay buttons ----------------------
proc Attack
% setscreen ("graphics:600;600,offscreenonly")
% var cellAttack : string
% locate (30, 69)
put "ATTACK!!"
% get cellAttack : *
% var cellattack : int := Pic.FileNew ("attack.bmp")
% Pic.Draw (cellattack, 480, 120, 0)
% CODE FOR CARRYING OUT ANIMATION FOR ATTACK GOES HERE
end Attack
proc Wait
locate (1, 1)
put "You chose to wait"
end Wait
% -------------------MENU SELECTION PROCEDURES---------------
proc Credits
locate (1, 1)
put "You chose the Credits"
end Credits
proc Quit
Window.Close (Window.GetActive)
end Quit
% ---- CURSOR MOVEMENT WITH MAP ----
proc cursormovement
View.Set ("graphics:660;660,offscreenonly,cursor,echo")
var key : array char of boolean
var px : int := 1
var py : int := 19 % we start off at grid 1,19
% -------- PLAYER ONE SPLASH ----------
var font1 : int
font1 := Font.New ("tahoma:20:bold,italic")
% ----------------------------
% ---- Collision Detection Cursor Variables ------
var cursor_btm_left_X, cursor_btm_left_Y : int
% ------------------------------------------------
% STARTING POINTS OF THE UNITS WITH THE BOXES AROUND THEM
var tank1_x, tank1_y : int
tank1_x := 120
tank1_y := 210
%-------------------
var artillery1_x, artillery1_y : int
artillery1_x := 60
artillery1_y := 360
% ------------------
var mdtank1_x, mdtank1_y : int
mdtank1_x := 120
mdtank1_y := 300
% ------------------
var bazooka1_x, bazooka1_y : int
bazooka1_x := 150
bazooka1_y := 570
% -----------------
var infantry1_x, infantry1_y : int
infantry1_x := 60
infantry1_y := 450
% -----------------
loop
reDraw
% draw RED TEAM UNITS ==============================
Pic.SetTransparentColor (tank1, white)
%move procedure consists of
% getting the future co-ords of where the unit will move
% adding the difference to tank1_x and tank1_y to move it
Pic.Draw (tank1, tank1_x, tank1_y, picMerge)
Draw.Dot (tank1_x, tank1_y, 191)
Draw.Box (tank1_x + 1, tank1_y + 1, tank1_x + 29, tank1_y + 29, brightred)
% #########################################
Pic.SetTransparentColor (artillery1, white)
%move procedure consists of
% getting the future co-ords of where the unit will move
% adding the difference to artillery1_x and artillery1_y to move it
Pic.Draw (artillery1, artillery1_x, artillery1_y, picMerge)
Draw.Dot (artillery1_x, artillery1_y, 2)
Draw.Box (artillery1_x + 1, artillery1_y + 1, artillery1_x + 29, artillery1_y + 29, brightred)
% ###########################################
Pic.SetTransparentColor (mdtank1, white)
%move procedure consists of
% getting the future co-ords of where the unit will move
% adding the difference to mdtank1_x and mdtank1_y to move it
Pic.Draw (mdtank1, mdtank1_x, mdtank1_y, picMerge)
Draw.Dot (mdtank1_x, mdtank1_y, 190)
Draw.Box (mdtank1_x + 1, mdtank1_y + 1, mdtank1_x + 29, mdtank1_y + 29, brightred)
% ###########################################
Pic.SetTransparentColor (bazooka1, white)
%move procedure consists of
% getting the future co-ords of where the unit will move
% adding the difference to bazooka1_x and bazooka1_y to move it
Pic.Draw (bazooka1, bazooka1_x, bazooka1_y, picMerge)
Draw.Dot (bazooka1_x, bazooka1_y, 119)
Draw.Box (bazooka1_x + 1, bazooka1_y + 1, bazooka1_x + 29, bazooka1_y + 29, brightred)
%##########################################
Pic.SetTransparentColor (infantry1, white)
%move procedure consists of
% getting the future co-ords of where the unit will move
% adding the difference to infantry1_x and infantry1_y to move it
Pic.Draw (infantry1, infantry1_x, infantry1_y, picMerge)
Draw.Dot (infantry1_x, infantry1_y, 120)
Draw.Box (infantry1_x + 1, infantry1_y + 1, infantry1_x + 29, infantry1_y + 29, brightred)
% =====================================================
% >>>> all active text goes here <<<<
%border
drawfillbox (0, 630, 660, 660, black)
drawfillbox (0, 145, 660, 180, black)
drawfillbox (0, 150, 30, 660, black)
drawfillbox (630, 150, 660, 660, black)
% --- draws player one box ---
drawfillbox (250, 45, 388, 89, 199)
drawfillbox (257, 49, 382, 85, 45)
Font.Draw ("Player 1", 265, 60, font1, 17)
Font.Draw ("Player 1", 270, 54, font1, 41)
locate (31, 1)
colourback (black)
colour (white)
put " Status :/> "
% ++++++++++++++++++++++++++++++++++
Input.KeyDown (key )
% Movement of the cursor on the screen.
if key (KEY_LEFT_ARROW) and tiles (px - 1, py ) = 0 then
px - = 1
delay (30)
end if
if key (KEY_RIGHT_ARROW) and tiles (px + 1, py ) = 0 then
px + = 1
delay (30)
end if
if key (KEY_DOWN_ARROW) and tiles (px, py - 1) = 0 then
py - = 1
delay (30)
end if
if key (KEY_UP_ARROW) and tiles (px, py + 1) = 0 then
py + = 1
delay (30)
end if
% THIS IS THE SECTION WHERE THE PROMPT IS MADE!! ###########################
if key ('m') and whatdotcolour (cursor_btm_left_X, cursor_btm_left_Y ) = 2 then % ARTILLERY
locate(35, 9)
colour(black)
get artillery1_x
locate (35, 9)
get artillery1_y
drawfillbox(150, 150, 180, 180, yellow)
end if
% ########################################
if key ('z') then % Unit options
% place buttons in bottom right corner
% BORDER lines at the bottom
drawline (180, 0, 180, 150, black)
drawline (450, 0, 450, 150, black)
drawline (0, 150, 660, 150, black)
if whatdotcolour (cursor_btm_left_X,cursor_btm_left_Y ) not= 191 and whatdotcolour (cursor_btm_left_X,cursor_btm_left_Y ) not= 190 and whatdotcolour (cursor_btm_left_X,cursor_btm_left_Y ) not= 2 and whatdotcolour (cursor_btm_left_X,cursor_btm_left_Y ) not= 119 and whatdotcolour (cursor_btm_left_X,cursor_btm_left_Y ) not= 120 then
locate (31, 13)
put "No Unit Present"
% END TURN PROCEDURE GOES IN HERE
else
loop
locate (31, 15)
put "Unit selected.... awaiting commands"
Draw.Box (px * 30, py * 30, px * 30 + 30, py * 30 + 30, black)
var button1 : int := GUI.CreateButton (480, 5, 0, " Cancel ", cursormovement )
var button2 : int := GUI.CreateButton (480, 30, 0, " Wait ", Wait )
var button3 : int := GUI.CreateButton (480, 55, 0, " Attack ", Attack )
exit when GUI.ProcessEvent
View.Update
end loop
end if
end if
% draws the cursor of the game, white outlined
cursor_btm_left_X := px * 30
cursor_btm_left_Y := py * 30
drawline (px * 30 + 1, py * 30 + 29, px * 30 + 29, py * 30 + 29, white) % top of the cursor
drawline (px * 30 + 29, py * 30 + 1, px * 30 + 29, py * 30 + 29, white) %right side of cursor
drawline (px * 30 + 1, py * 30 + 1, px * 30 + 1, py * 30 + 29, white) %Left Side
drawline (cursor_btm_left_X + 1, cursor_btm_left_Y + 1, px * 30 + 29, py * 30 + 1, white) %Bottom of the cursor
% >>> WHAT DOT COLOUR FOR DETERMINING THE UNIT TYPE <<<<
if whatdotcolour (cursor_btm_left_X, cursor_btm_left_Y ) = 191 then
locate (31, 15)
colour (white)
put "Tank Co-Ordinates: " : 2, "x = (", cursor_btm_left_X, ") , y = (", cursor_btm_left_Y, ")"
locate (32, 15)
put "Press 'M' to move unit"
locate (35, 1)
colourback (white)
colour (black)
put "HP: ", tank1_health
end if
if whatdotcolour (cursor_btm_left_X, cursor_btm_left_Y ) = 2 then
locate (31, 15)
colour (white)
put "Artillery Co-Ordinates: " : 2, "x = (", cursor_btm_left_X, ") , y = (", cursor_btm_left_Y, ")"
locate (32, 15)
put "Press 'M' to move unit"
locate (35, 1)
colourback (white)
colour (black)
put "HP: ", artillery1_health
end if
if whatdotcolour (cursor_btm_left_X, cursor_btm_left_Y ) = 190 then
locate (31, 15)
colour (white)
put "Mid-Tank Co-Ordinates: " : 2, "x = (", cursor_btm_left_X, ") , y = (", cursor_btm_left_Y, ")"
locate (32, 15)
put "Press 'M' to move unit"
locate (35, 1)
colourback (white)
colour (black)
put "HP: ", mdtank1_health
end if
if whatdotcolour (cursor_btm_left_X, cursor_btm_left_Y ) = 119 then
locate (31, 15)
colour (white)
put "Bazooka Co-Ordinates: " : 2, "x = (", cursor_btm_left_X, ") , y = (", cursor_btm_left_Y, ")"
locate (32, 15)
put "Press 'M' to move unit"
locate (35, 1)
colourback (white)
colour (black)
put "HP: ", bazooka1_health
end if
if whatdotcolour (cursor_btm_left_X, cursor_btm_left_Y ) = 120 then
locate (31, 15)
colour (white)
put "Infantry Co-Ordinates: " : 2, "x = (", cursor_btm_left_X, ") , y = (", cursor_btm_left_Y, ")"
locate (32, 15)
put "Press 'M' to move unit"
locate (35, 1)
colourback (white)
colour (black)
put "HP: ", infantry1_health
end if
% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
% Displays cursor location.
locate (1, 38)
colourback (black)
colour (white)
put "Cursor Co-Ordinates: " : 2, "x = (", cursor_btm_left_X, ") , y = (", cursor_btm_left_Y, ")"
% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
colourback (white)
locate (34, 1)
colour (black)
put "Unit Stats"
drawline (180, 0, 180, 150, black)
drawline (450, 0, 450, 150, black)
drawline (0, 150, 660, 150, black)
View.Update
% Draws the map of level 1
Pic.Draw (level1, 30, 180, picMerge)
delay (90)
end loop
end cursormovement
proc MENU
loop
% ------------------- START MENU GAMEPLAY SELECTION --------------------
View.Set ("graphics:700;520,nobuttonbar,position:center;center")
var background : int := Pic.FileNew ("menuback.jpg")
Pic.Draw (background, 0, 0, 0)
loop
% these place the buttons on the menu.
var button1 : int := GUI.CreateButton (25, 25, 0, " Quit ", Quit )
var button2 : int := GUI.CreateButton (25, 50, 0, " Credits ", Credits )
var button3 : int := GUI.CreateButton (25, 75, 0, " Play! ", cursormovement )
loop
exit when GUI.ProcessEvent
end loop
end loop
end loop
end MENU
% actual start of game
% On school computers, there is a utility that allows a
% user to change their screen resolution.
% This procedure sets the resolution to 1024.
%if not Sys.Exec ("Resolution1024") then
% delay (1000)
% MENU
%end if
MENU
|
Please specify what version of Turing you are using
4.0.5
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
cavetroll
|
Posted: Sat May 30, 2009 11:02 am Post subject: RE:"get" prompt. Can\'t see what is being typed with cursor. |
|
|
'get' doesn't show the text if you are in 'offscreenonly' mode. Just change the screen to 'nooffscreenonly' before the prompt, and change it back after. |
|
|
|
|
|
tecnikal
|
Posted: Sat May 30, 2009 11:19 am Post subject: RE:"get" prompt. Can\'t see what is being typed with cursor. |
|
|
Thank you very much cavetroll.
It worked |
|
|
|
|
|
|
|