
-----------------------------------
vdemons
Wed May 11, 2011 10:38 pm

3 Piano keys don't work?
-----------------------------------
Well I making a piano game for my class, that plays all the notes of the white piano keys however, only 3 out of 7 actually work.
I checked my work yet I can't find anything wrong with it can you please help?  

Also the notes that play in turing sound cut off can anyone tell me how to fix that?

Please and Thank you in Advance!

MY CODE!


% This program creates a fixed button box (button) on the screen and displays 
% "You have just pressed the button" when the mouse button is pressed.

% Sets the screen to VGA graphics mode.
setscreen ("graphics.vga")

% Declares the button positions coordinates as constants.
const keyc_x1 :=100
const keyc_y1 :=100
const keyc_x2 :=150
const keyc_y2 :=300

const keyd_x1 :=150
const keyd_y1 :=100
const keyd_x2 :=200
const keyd_y2 :=300

const keye_x1 :=200
const keye_y1 :=100
const keye_x2 :=250
const keye_y2 :=300

const keyf_x1 :=250
const keyf_y1 :=100
const keyf_x2 :=300
const keyf_y2 :=300

const keyg_x1 :=300
const keyg_y1 :=100
const keyg_x2 :=350
const keyg_y2 :=300

const keya_x1 :=350
const keya_y1 :=100
const keya_x2 :=400
const keya_y2 :=300

const keyb_x1 :=400
const keyb_y1 :=100
const keyb_x2 :=450
const keyb_y2 :=300

% Declares the mouse varibles 
var xmouse, ymouse, button:int

% Draws the box on the screen
Draw.Box (keyc_x1,keyc_y1,keyc_x2,keyc_y2, 20)
Draw.Box (keyd_x1,keyd_y1,keyd_x2,keyd_y2, 20)
Draw.Box (keye_x1,keye_y1,keye_x2,keye_y2, 20)
Draw.Box (keyf_x1,keyf_y1,keyf_x2,keyf_y2, 20)
Draw.Box (keyg_x1,keyg_y1,keyg_x2,keyg_y2, 20)
Draw.Box (keya_x1,keya_y1,keya_x2,keya_y2, 20)
Draw.Box (keyb_x1,keyb_y1,keyb_x2,keyb_y2, 20)


Draw.FillBox (140, 180, 160, 300, 12)
Draw.FillBox (190, 180, 210, 300, 12)
Draw.FillBox (290, 180, 310, 300, 12)
Draw.FillBox (340, 180, 360, 300, 12)
Draw.FillBox (390, 180, 410, 300, 12)

loop
    % Gets the mouse cursor status
    mousewhere(xmouse,ymouse,button)
    
    if button=1 and xmouse>=keyc_x1 and xmouse=keyc_y1 and xmouse=keyd_x1 and xmouse=keyd_y1 and xmouse=keye_x1 and xmouse=keye_y1 and xmouse=keyf_x1 and xmouse=keyf_y1 and xmouse=keyg_x1 and xmouse=keyg_y1 and xmouse=keya_x1 and xmouse=keya_y1 and xmouse=keyb_x1 and xmouse=keyb_y1 and xmouse=keya_x1 but i dont know how to fix it can you help i am not experienced enough.

-----------------------------------
Tony
Wed May 11, 2011 11:51 pm

RE:3 Piano keys don\'t work?
-----------------------------------
The ones that are working are working on accident. Don't look at them as "correct reference". Just look at the part that doesn't work in isolation.

-----------------------------------
vdemons
Thu May 12, 2011 12:26 am

RE:3 Piano keys don\'t work?
-----------------------------------
The problem is that i got these "custom made buttons" for my teacher and was told to use them, so i don't know what to do if there wrong.

-----------------------------------
vdemons
Thu May 12, 2011 12:27 am

RE:3 Piano keys don\'t work?
-----------------------------------
This was his example:

% This program creates a fixed button box (button) on the screen and displays 
% "You have just pressed the button" when the mouse button is pressed.

% Sets the screen to VGA graphics mode.
setscreen ("graphics.vga")

% Declares the button positions coordinates as constants.
const BUTTON_X1 :=60
const BUTTON_Y1 :=60
const BUTTON_X2 :=120
const BUTTON_Y2 :=120

% Declares the mouse varibles 
var xmouse, ymouse, button:int

% Draws the box on the screen
drawbox(BUTTON_X1,BUTTON_Y1,BUTTON_X2,BUTTON_Y2,15)
loop
    % Gets the mouse cursor status
    mousewhere(xmouse,ymouse,button)
    
    % Keeps looping until the coordinates of the mouse are within
    % button's coordinates and the mouse button is pressed 
    exit when button=1 and xmouse>=BUTTON_X1 and xmouse=BUTTON_Y1 and xmouse