Computer Science Canada Help with my little game |
Author: | aaron1046 [ Tue Jan 13, 2009 8:22 am ] |
Post subject: | Help with my little game |
Ok, im making a small really basic turing game for school for computers (Dhu) And I'm having issuse.. Ok the game is like a maze, you move around, can't hit the walls, the walls 3 times you die and restart. Also you can get "keys" I guess u could call them that open the door to move on. Tho I'm having alot of difficulty.. Some with the cant hit the wall thing, I make some walls work but those few walls I did took like 4 hours to get to WORK!! Maybe some one can help me out? OR can help me finish it PLEASE!! TY! |
Author: | TheGuardian001 [ Tue Jan 13, 2009 3:19 pm ] |
Post subject: | Re: Help with my little game |
if you want this program to work properly, you are either going to need arrays to hold the x and y values of each box, or to use View.WhatDotColour. Arrays would be advisable if you have had some experience using them, and would work better in the long run, however if you have no knowledge of arrays then View.WhatDotColour will work, although it is generally frowned upon. collisions with arrays essentially work the same way as your current collision detection, however you can easily check every value in a simple for statement. I would advise you to read the tutorial on arrays and try to use them. Mod Edit: Fixed broken URL tag. No need for the quotes around the actual url. |
Author: | saltpro15 [ Tue Jan 13, 2009 3:36 pm ] |
Post subject: | RE:Help with my little game |
I would advise the use of procedures instead of massive loops. that way you're main loop is only about 15-20 lines long, and you only have to put 1 view.update in. |
Author: | aaron1046 [ Tue Jan 13, 2009 8:12 pm ] |
Post subject: | RE:Help with my little game |
well sucks my class is only half a school year and this is my first year using turing, I don't know much of what you talk about BUT ill read about it to see what I can find out. Still looking for help to finish my program if any 1 can help me With my game Im trying to make a maze like game, can't touch the walls more then.. lets say 3-5 times. if so u die game over screen comes up. U can get the items to open doors... Thats about it.. |
Author: | ecookman [ Tue Jan 13, 2009 9:24 pm ] |
Post subject: | RE:Help with my little game |
If you have no background in programming like using arrays, if statements,ect this is one hell of a task to take on... if I were you...i would do this as something extra and work on class assignments, building knoweldge on the fundamentals and then!, using all of your knoweldge create something really cool. If this is your first crack at programming you will find out shortly (depending on how well you can take in and understand stuff) that you want to hang your self. unfortunately i am unable to download the file, but i have tried to do something simmilar. basically for the colosisions: for your walls set the points of them, take those points and make it so if anything touches it X happens (i think use boolean) basically talking out the code it will be if the mouse touches the wall the expression if salse, soo you loose a life. As a constant if the mouse isn't touching anyone of the points the expression is true untill interupted. basically lots of if statements and boolean the lives is surprisingly the easy part.... wil look something like var life : (i think) int life:={what number that you want} if mouse touches wall boolean expression = false = life-1, reset (<-not actual code) ---------------------edit---------------------------------------- if anyone knows of a more efficent way to do this please say so....i have said everythig to the extent of my knoweldge, and like all of us, we make mistakes personally i am just starting to figure out boolean, but i am pretty sure that i have the basic principals down for this game |
Author: | aaron1046 [ Tue Jan 13, 2009 9:44 pm ] |
Post subject: | RE:Help with my little game |
Im using keys to move. And this is a BIG project. My computer class ends I think the end of next week. THIS NEEDS TO BE DONE |
Author: | ecookman [ Sun Jan 18, 2009 8:38 pm ] |
Post subject: | RE:Help with my little game |
ooooh sorry then i have no clue.... as i said..go for something easier like.....pong..there are many tutorials on how to make pong |
Author: | A.J [ Sun Jan 18, 2009 10:16 pm ] |
Post subject: | Re: Help with my little game |
ecookman wrote: ooooh sorry then i have no clue.... as i said..go for something easier like.....pong..there are many tutorials on how to make pong don't discourage people! encourage them! I can't open your file (since i dont have winRAR). Do u mind showing me your code so that I can help u w/ this? moving around in a maze is actually very simple, and u shud be able to finish it well (dont listen to ecookman ) |
Author: | aaron1046 [ Wed Jan 21, 2009 9:18 am ] |
Post subject: | Re: Help with my little game |
Well to late anways its du today (In the class now) But heres the code anyways! note: Alot of the code is not use right now, was use for other plans var chars : array char of boolean var x, y, xx, yy, q, w, qq, ww, count : int var cc, vv, button : int var font1 : int := Font.New ("Souvenir Lt BT:32:bold,italic") var pic1 : int var pic2 : int count := 0 x := 14 y := 155 xx := 24 yy := 165 q := 15 w := 54 qq := 10 ww := 68 pic1 := Pic.FileNew ("maze-icon.gif") pic2 := Pic.FileNew ("backyyyy.gif") View.Set ("offscreenonly") %%%%%%% %Title% %%%%%%% process DoMusic1 loop Music.PlayFile ("t1.mid") end loop end DoMusic1 fork DoMusic1 loop locate (1, 1) View.Update mousewhere (cc, vv, button) Pic.Draw (pic2, 0, 0, picCopy) Pic.Draw (pic1, 150, 50, picCopy) Font.Draw ("Click Anywhere to play!", 50, 20, font1, 12) if cc >= 0 and vv <= 650 and cc >= 0 and vv <= 400 and button = 1 then View.Update cls exit end if end loop %%%%%% %Game% %%%%%% %%%%%% %song2% process DoMusic2 loop Music.PlayFile ("t2.mid") end loop end DoMusic2 fork DoMusic2 View.Update loop drawfillbox (15, 54, 10, 68, 13) %Item1% drawfillbox (15, 284, 10, 298, 13) %Item2% drawfillbox (120, 80, 125, 50, 12) %door1% drawfillbox (120, 300, 125, 270, 2) %door2% drawfillbox (0, 280, 40, 180, 18) %#1 drawfillbox (120, 80, 140, 212, 22) %#2 drawfillbox (120, 180, 40, 212, 33) %#3 drawfillbox (0, 80, 100, 112, 45) %#4 drawfillbox (0, 20, 350, 50, 66) %#5 drawfillbox (200, 20, 230, 255, 89) %#6 drawfilloval (185, 50, 30, 30, 123) %#7 drawfilloval (152, 140, 30, 30, 2) %#8 drawfillbox (230, 240, 70, 272, 164) %#9 drawfillbox (0, 330, 300, 300, 190) %#10 drawfillbox (0, 300, 5, 30, 200) %#11 drawfillbox (260, 330, 300, 70, 133) %#12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Input.KeyDown (chars) locate (1, 1) drawfillbox (x, y, x + 10, y + 10, 22) %Guy% if chars (KEY_RIGHT_ARROW) then x := x + 1 xx := xx + 1 View.Update delay (3) cls end if if chars (KEY_UP_ARROW) then y := y + 1 yy := yy + 1 View.Update delay (3) cls end if if chars (KEY_DOWN_ARROW) then y := y + -1 yy := yy + -1 View.Update delay (3) cls end if if chars (KEY_LEFT_ARROW) then x := x + -1 xx := xx + -1 View.Update delay (3) cls end if if y = -76 then y := 474 end if if y = 475 then y := -75 end if if x = 715 then x := -75 end if if x = -76 then x := 714 end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %Bad Walls% % #3 %Bottem if x = 180 and x <= 139 then x := 180 - 4 %count = count + 1 end if if y = 170 and x <= 139 then y := 170 - 4 %Top end if if y = 210 and x <= 139 then y := 210 + 4 %count = count + 1 end if %%%%%%%%%%%%%%%%%%%%%%% % #2 % %Left if x >= 110 and y <= 212 and y >= 70 and x <= 134 then x := 110 - 4 %count = count + 1 end if if x <= 138 and x >= 110 and y <= 212 and y >= 80 then x := 138 + 4 end if % #4 % if x >= 0 and y <= 112 and y >= 70 and x <= 85 then y := y + 4 end if %drawfillbox (0, 80, 100, 112, 45) %% drawfillbox (120, 80, 140, 212, 22) %Left,bottem,right,top % if count = 5 then % end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %out of the box% if x = 0 then x := 0 + 1 end if if y = 0 then y := 0 + 1 end if if xx = 10 then xx := 10 + 1 end if if yy = 10 then yy := 10 + 1 end if %out of the box% if xx = 640 then xx := 640 - 1 end if if yy = 400 then yy := 400 - 1 end if if x = 630 then x := 630 - 1 end if if y = 390 then y := 390 - 1 end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Item1% drawfillbox (15, 54, 10, 68, 13) %Item% if x >= 15 and x <= 17 and y >= 10 and y <= 68 then cls exit end if end loop % q := 15 % w := 54 % qq := 10 % ww := 68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% View.Update loop %drawfillbox (15, 54, 10, 68, 13) %Item1% drawfillbox (15, 284, 10, 298, 13) %Item2% %drawfillbox (120, 80, 125, 50, 12) %door1% drawfillbox (120, 300, 125, 270, 2) %door2% drawfillbox (0, 280, 40, 180, 18) %1 drawfillbox (120, 80, 140, 212, 22) %2 drawfillbox (120, 180, 40, 212, 33) %3 drawfillbox (0, 80, 100, 112, 45) %4 drawfillbox (0, 20, 350, 50, 66) %5 drawfillbox (200, 20, 230, 255, 89) %6 drawfilloval (185, 50, 30, 30, 123) %7 drawfilloval (152, 140, 30, 30, 2) %8 drawfillbox (230, 240, 70, 272, 164) %9 drawfillbox (0, 330, 300, 300, 190) %10 drawfillbox (0, 300, 5, 30, 200) %11 drawfillbox (260, 330, 300, 70, 133) %12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Input.KeyDown (chars) locate (1, 1) drawfillbox (x, y, x + 10, y + 10, 22) %Guy% if chars (KEY_RIGHT_ARROW) then x := x + 1 xx := xx + 1 View.Update delay (3) cls end if if chars (KEY_UP_ARROW) then y := y + 1 yy := yy + 1 View.Update delay (3) cls end if if chars (KEY_DOWN_ARROW) then y := y + -1 yy := yy + -1 View.Update delay (3) cls end if if chars (KEY_LEFT_ARROW) then x := x + -1 xx := xx + -1 View.Update delay (3) cls end if if y = -76 then y := 474 end if if y = 475 then y := -75 end if if x = 715 then x := -75 end if if x = -76 then x := 714 end if %Left,bottem,right,top %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %Bad Walls% % #3 %Bottem if x = 180 and x <= 139 then x := 180 - 4 %count = count + 1 end if if y = 170 and x <= 139 then y := 170 - 4 %Top end if if y = 210 and x <= 139 then y := 210 + 4 %count = count + 1 end if %%%%%%%%%%%%%%%%%%%%%%% % #2 % %Left if x >= 110 and y <= 212 and y >= 70 and x <= 134 then x := 110 - 4 %count = count + 1 end if if x <= 138 and x >= 110 and y <= 212 and y >= 80 then x := 138 + 4 end if % X , y , 10, 10 % Grayright 120, 80, 140, 212, % if count = 5 then % end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %out of the box% if x = 0 then x := 0 + 1 end if if y = 0 then y := 0 + 1 end if if xx = 10 then xx := 10 + 1 end if if yy = 10 then yy := 10 + 1 end if %out of the box% if xx = 640 then xx := 640 - 1 end if if yy = 400 then yy := 400 - 1 end if if x = 630 then x := 630 - 1 end if if y = 390 then y := 390 - 1 end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Item1% drawfillbox (15, 54, 10, 68, 13) %Item% if x >= 15 and x <= 17 and y >= 10 and y <= 68 then cls exit end if end loop |
Author: | aaron1046 [ Wed Jan 21, 2009 9:18 am ] |
Post subject: | Re: Help with my little game |
Well to late anways its du today (In the class now) But heres the code anyways! note: Alot of the code is not use right now, was use for other plans var chars : array char of boolean var x, y, xx, yy, q, w, qq, ww, count : int var cc, vv, button : int var font1 : int := Font.New ("Souvenir Lt BT:32:bold,italic") var pic1 : int var pic2 : int count := 0 x := 14 y := 155 xx := 24 yy := 165 q := 15 w := 54 qq := 10 ww := 68 pic1 := Pic.FileNew ("maze-icon.gif") pic2 := Pic.FileNew ("backyyyy.gif") View.Set ("offscreenonly") %%%%%%% %Title% %%%%%%% process DoMusic1 loop Music.PlayFile ("t1.mid") end loop end DoMusic1 fork DoMusic1 loop locate (1, 1) View.Update mousewhere (cc, vv, button) Pic.Draw (pic2, 0, 0, picCopy) Pic.Draw (pic1, 150, 50, picCopy) Font.Draw ("Click Anywhere to play!", 50, 20, font1, 12) if cc >= 0 and vv <= 650 and cc >= 0 and vv <= 400 and button = 1 then View.Update cls exit end if end loop %%%%%% %Game% %%%%%% %%%%%% %song2% process DoMusic2 loop Music.PlayFile ("t2.mid") end loop end DoMusic2 fork DoMusic2 View.Update loop drawfillbox (15, 54, 10, 68, 13) %Item1% drawfillbox (15, 284, 10, 298, 13) %Item2% drawfillbox (120, 80, 125, 50, 12) %door1% drawfillbox (120, 300, 125, 270, 2) %door2% drawfillbox (0, 280, 40, 180, 18) %#1 drawfillbox (120, 80, 140, 212, 22) %#2 drawfillbox (120, 180, 40, 212, 33) %#3 drawfillbox (0, 80, 100, 112, 45) %#4 drawfillbox (0, 20, 350, 50, 66) %#5 drawfillbox (200, 20, 230, 255, 89) %#6 drawfilloval (185, 50, 30, 30, 123) %#7 drawfilloval (152, 140, 30, 30, 2) %#8 drawfillbox (230, 240, 70, 272, 164) %#9 drawfillbox (0, 330, 300, 300, 190) %#10 drawfillbox (0, 300, 5, 30, 200) %#11 drawfillbox (260, 330, 300, 70, 133) %#12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Input.KeyDown (chars) locate (1, 1) drawfillbox (x, y, x + 10, y + 10, 22) %Guy% if chars (KEY_RIGHT_ARROW) then x := x + 1 xx := xx + 1 View.Update delay (3) cls end if if chars (KEY_UP_ARROW) then y := y + 1 yy := yy + 1 View.Update delay (3) cls end if if chars (KEY_DOWN_ARROW) then y := y + -1 yy := yy + -1 View.Update delay (3) cls end if if chars (KEY_LEFT_ARROW) then x := x + -1 xx := xx + -1 View.Update delay (3) cls end if if y = -76 then y := 474 end if if y = 475 then y := -75 end if if x = 715 then x := -75 end if if x = -76 then x := 714 end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %Bad Walls% % #3 %Bottem if x = 180 and x <= 139 then x := 180 - 4 %count = count + 1 end if if y = 170 and x <= 139 then y := 170 - 4 %Top end if if y = 210 and x <= 139 then y := 210 + 4 %count = count + 1 end if %%%%%%%%%%%%%%%%%%%%%%% % #2 % %Left if x >= 110 and y <= 212 and y >= 70 and x <= 134 then x := 110 - 4 %count = count + 1 end if if x <= 138 and x >= 110 and y <= 212 and y >= 80 then x := 138 + 4 end if % #4 % if x >= 0 and y <= 112 and y >= 70 and x <= 85 then y := y + 4 end if %drawfillbox (0, 80, 100, 112, 45) %% drawfillbox (120, 80, 140, 212, 22) %Left,bottem,right,top % if count = 5 then % end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %out of the box% if x = 0 then x := 0 + 1 end if if y = 0 then y := 0 + 1 end if if xx = 10 then xx := 10 + 1 end if if yy = 10 then yy := 10 + 1 end if %out of the box% if xx = 640 then xx := 640 - 1 end if if yy = 400 then yy := 400 - 1 end if if x = 630 then x := 630 - 1 end if if y = 390 then y := 390 - 1 end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Item1% drawfillbox (15, 54, 10, 68, 13) %Item% if x >= 15 and x <= 17 and y >= 10 and y <= 68 then cls exit end if end loop % q := 15 % w := 54 % qq := 10 % ww := 68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% View.Update loop %drawfillbox (15, 54, 10, 68, 13) %Item1% drawfillbox (15, 284, 10, 298, 13) %Item2% %drawfillbox (120, 80, 125, 50, 12) %door1% drawfillbox (120, 300, 125, 270, 2) %door2% drawfillbox (0, 280, 40, 180, 18) %1 drawfillbox (120, 80, 140, 212, 22) %2 drawfillbox (120, 180, 40, 212, 33) %3 drawfillbox (0, 80, 100, 112, 45) %4 drawfillbox (0, 20, 350, 50, 66) %5 drawfillbox (200, 20, 230, 255, 89) %6 drawfilloval (185, 50, 30, 30, 123) %7 drawfilloval (152, 140, 30, 30, 2) %8 drawfillbox (230, 240, 70, 272, 164) %9 drawfillbox (0, 330, 300, 300, 190) %10 drawfillbox (0, 300, 5, 30, 200) %11 drawfillbox (260, 330, 300, 70, 133) %12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Input.KeyDown (chars) locate (1, 1) drawfillbox (x, y, x + 10, y + 10, 22) %Guy% if chars (KEY_RIGHT_ARROW) then x := x + 1 xx := xx + 1 View.Update delay (3) cls end if if chars (KEY_UP_ARROW) then y := y + 1 yy := yy + 1 View.Update delay (3) cls end if if chars (KEY_DOWN_ARROW) then y := y + -1 yy := yy + -1 View.Update delay (3) cls end if if chars (KEY_LEFT_ARROW) then x := x + -1 xx := xx + -1 View.Update delay (3) cls end if if y = -76 then y := 474 end if if y = 475 then y := -75 end if if x = 715 then x := -75 end if if x = -76 then x := 714 end if %Left,bottem,right,top %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %Bad Walls% % #3 %Bottem if x = 180 and x <= 139 then x := 180 - 4 %count = count + 1 end if if y = 170 and x <= 139 then y := 170 - 4 %Top end if if y = 210 and x <= 139 then y := 210 + 4 %count = count + 1 end if %%%%%%%%%%%%%%%%%%%%%%% % #2 % %Left if x >= 110 and y <= 212 and y >= 70 and x <= 134 then x := 110 - 4 %count = count + 1 end if if x <= 138 and x >= 110 and y <= 212 and y >= 80 then x := 138 + 4 end if % X , y , 10, 10 % Grayright 120, 80, 140, 212, % if count = 5 then % end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %out of the box% if x = 0 then x := 0 + 1 end if if y = 0 then y := 0 + 1 end if if xx = 10 then xx := 10 + 1 end if if yy = 10 then yy := 10 + 1 end if %out of the box% if xx = 640 then xx := 640 - 1 end if if yy = 400 then yy := 400 - 1 end if if x = 630 then x := 630 - 1 end if if y = 390 then y := 390 - 1 end if %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Item1% drawfillbox (15, 54, 10, 68, 13) %Item% if x >= 15 and x <= 17 and y >= 10 and y <= 68 then cls exit end if end loop Edit: Sorry for duble post |