Flickerating Font.Draw
Author |
Message |
Mr. T
![](http://www.madpaintballer.com/images/purepwnage.gif)
|
Posted: Wed Apr 06, 2005 7:53 pm Post subject: Flickerating Font.Draw |
|
|
how can i make the madness end?
code: |
%%%%%%%%%%%
% CASHIER %
%%%%%%%%%%%%%%%
% BLING-BLING %
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Variable Declaration
colour (0)
colourback (7)
cls
View.Set ("offscreenonly")
var slidingTitle : int := 0
var titleFont, shopFont : int
titleFont := Font.New ("serif:80")
shopFont := Font.New ("serif:20")
var x, y, button : int
var increase : int := 5
var foodItems : array 1 .. 5 of string
foodItems (1) := "Cheese Blintz"
foodItems (2) := "Corn Muffin"
foodItems (3) := "Cactus Juice"
foodItems (4) := "Moldy Cheese"
foodItems (5) := "Liver Shnitzel"
var foodPrices : array 1 .. 5 of real
foodPrices (1) := 4.59
foodPrices (2) := 5.49
foodPrices (3) := 9.99
foodPrices (4) := 15.01
foodPrices (5) := 20.33
var listOrder : int := 3
var answer : int
var addItems, addPrices : int
var foodNames : string
var itemSelect : int
var priceSelect : real
var recallName : int
var newPrice : real
%Intro Procedure
%note: View.Update was the best way to avoid streaking and flickering
procedure intro
for title : 1 .. 500
colour (0)
colourback (7)
Font.Draw (" Jane & Finch", title - 500, 300, titleFont, brightred)
Font.Draw (" Super Store ", 500 - title, 100, titleFont, brightred)
cls
View.Update
end for
View.Set ("nooffscreenonly") %end of animations, output will be drawn on screen
%%%Entrance Point%%%
Draw.FillBox (240, 200, 422, 230, 0)
loop
mousewhere (x, y, button)
if button = 0 and whatdotcolour (x, y) = white then %button is not pressed and the mouse is over the entrance point
locate (12, 32)
put "[ALEX YOUNG OWNS YOU]" ..
delay (100)
elsif button = 0 and whatdotcolour (x, y) not= white then %button is not pressed and the mouse is not over the entrance point
locate (12, 32)
put "[CLICK HERE TO ENTER]" ..
delay (100)
elsif button = 1 and whatdotcolour (x, y) = white then %entering the store if button is pressed over the entrance point
delay (1000)
cls
exit
end if
end loop
end intro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Innitial Output
procedure innitialShop
drawline (1, maxy - 25, 400, maxy - 25, 0) %horizontal line for item/price list
drawline (200, 0, 200, maxy, 0) %vertical line for item/price list
Font.Draw ("Item", 70, maxy - 20, shopFont, brightred)
Font.Draw ("Price ($)", 260, maxy - 20, shopFont, brightred)
for i : 1 .. 5
locate (listOrder, 1) %location of each consecutive item
put foodItems (i) .. %.. so that the items do not cut off the vertical line for the item/price list
listOrder += 1 %each consecutive item is located 1 line below the previous
locate (listOrder - 1, 30)
put foodPrices (i)
end for
end innitialShop
View.Set ("nooffscreenonly")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Changing Around The Shop
procedure changeShop
Font.Draw ("Once In A Life Time Choice", maxx - 320, 110, shopFont, brightred)
drawbox (maxx - 330, 10, maxx - 5, 100, 0)
locate (20, 53)
put "Do you wish to:" ..
locate (21, 40)
put "1. Add an item / corresponding price?" ..
locate (22, 40)
put "2. Change a price?" ..
locate (23, 40)
put "3. Make a Purchase?" ..
locate (24, 40)
put "[Enter number of choice] " ..
get answer
loop
%Input For New Items / Corresponding Prices (OPTION #1)
if answer = 1 %add an item / corresponding price option was chosen
then
cls
put "How many items would you like to add? " ..
get addItems
addPrices := addItems
var addFoodItems : array 1 .. addItems of string
for a : 1 .. addItems
put "Item # ", a, " to be added shall be named? " ..
get addFoodItems (a) : *
end for
%Input for New Prices
var addFoodPrices : array 1 .. addPrices of real
for b : 1 .. addPrices
put "How much should item #", b, " cost? " ..
get addFoodPrices (b)
end for
cls %clears the input section
%Output For New Items
listOrder := 3 %miniature variable reset
innitialShop %procedure displaying the original items
for a : 1 .. addItems
locate (listOrder, 1) %situated beneath the preset items in the items column
put addFoodItems (a) ..
listOrder += 1
end for
%Output for New Prices
listOrder := 3 %miniature variable reset
innitialShop %procedure displaying the original items
for b : 1 .. addPrices
locate (listOrder, 30) %situated beneath the preset prices in the price column
put addFoodPrices (b) : 2 : 2 ..
listOrder += 1
end for
end if
%Changing The Price Of A Specific Item
if answer = 2 then
put "Select an item: " ..
get recallName %name location within the array
put "What should the price of a ", foodItems (recallName), " be changed to?" %displays the item numbers name
get newPrice %new price
foodPrices (recallName) := newPrice %insert new price into the array
cls
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
exit
end loop
listOrder := 3 %miniature variable reset
innitialShop
changeShop
end changeShop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%First Time Running The Program
intro
innitialShop
changeShop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Naveg
|
Posted: Wed Apr 06, 2005 8:05 pm Post subject: (No subject) |
|
|
try putting a View.Update right before every end loop, its the most common place where causes of flickering may happen |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Wed Apr 06, 2005 8:13 pm Post subject: (No subject) |
|
|
Changes:
- color/colorback moved outside of for loop (no need to be inside)
- changed for loop to 0 .. 500 by 5 (no one's going to want to wait that long)
- cls goes before the Font.Draw's
- View.Set ("offscreenonly") was moved above the calling of the proc.
and that about does it for now, i didn't look at the rest of your program though, ask if there's anything wrong with that. |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Wed Apr 06, 2005 8:18 pm Post subject: (No subject) |
|
|
Vladimir wrote: try putting a View.Update right before every end loop, its the most common place where causes of flickering may happen
You're going to want to put it after you've drawn everything. In some programs you do use, (do i dare say) processes, but if you were to run a loop in the process and a main loop, and you have one View.Update in the process, and one in the main loop, it's gonna flicker. The easiest thing to do is make a procedure dedicated to drawing everything necessary, such as:
code: | proc refresh
cls
%Draw.Fart (whatever)
View.Update
end refresh
|
And just put that in your loop. |
|
|
|
|
![](images/spacer.gif) |
Mr. T
![](http://www.madpaintballer.com/images/purepwnage.gif)
|
Posted: Wed Apr 06, 2005 8:26 pm Post subject: (No subject) |
|
|
thnx, got it.
New question, look at my code below.
I ask the user to input a new price for one of the preset food items. how can make it so that it will also automatically give me 2 values after the decimal place?
code: |
if answer = 2 then
Font.Draw("Price Alteration",maxx - 210,maxy-90,shopFont,brightred)
drawbox (400, maxy - 200, maxx - 10, maxy - 100, 0)
locate (8, 52)
put "Select an item: " ..
get recallName %name location within the array
locate (9, 52)
put foodItems (recallName), " cost:".. %displays the item numbers name
locate (10, 52)
put "$"..
get newPrice %new price
foodPrices (recallName) := newPrice %insert new price into the array
cls
end if
|
|
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Wed Apr 06, 2005 8:31 pm Post subject: (No subject) |
|
|
I'm not too too sure, but this is what i have, it works and all, but there's probabily an easier way to do it
code: | var numb : real := 9.9876543
var thing : string
thing := erealstr (numb, 2, 2, 2)
put strreal (thing) |
|
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Thu Apr 07, 2005 3:33 pm Post subject: (No subject) |
|
|
Pwned wrote: how can make it so that it will also automatically give me 2 values after the decimal place?
link
Jamonathin: try your code with numb := a three digit number.
It seems erealstr's fractionWidth parameter starts at 0 at the beginning of the number, not at the decimal place. |
|
|
|
|
![](images/spacer.gif) |
Token
![](http://server2.uploadit.org/files/token89-avatar1.jpg)
|
Posted: Thu Apr 07, 2005 5:30 pm Post subject: (No subject) |
|
|
all that you have to do is change
code: |
put addFoodPrices (b) ..
|
to
code: |
put addFoodPrices (b) : 2 : 2 ..
|
i showed him this on msn but i figured i'd post it just for others who were inturested. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|