help with my game please- I need the character to eat something
Author |
Message |
turing1094
|
Posted: Sun Jun 13, 2010 1:54 pm Post subject: help with my game please- I need the character to eat something |
|
|
What is it you are trying to achieve?
I am trying to make a game where there is a player who has to eat dots on the screen. As he eats the food the score should go up
What is the problem you are having?
I am having trouble getting the player to eat the food(dots)
Describe what you have tried to solve this problem
I have no clue where to start
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
%%%%%%%%%%%%%%%%
%% Turing Game %%
%%%%%%%%%%%%%%%%
% These are some variables that need to be declared to make the game work correctly
var chars : array char of boolean
var x1 : int := 1 % This is the position of the object (x1)
var x2 : int := x1 + 10 % This is the position of the object (x2)
var y1 : int := 1 % This is the position of the object (y1)
var y2 : int := y1 + 10 % This variable represents the position of the object (y2)
var xv : real := 0 % This variable is the speed for the objects
var yv : real := 0 % This variable is the y value speed
var g : real := 1 % This is the gravity
var ground : boolean := true % This variable checks to see if the object is on the ground
var count : int := 0
var speed : int
var level : int % This step is the variable for picking your difficulty
var foodx : int := 325
var foody : int := 205
var delayinterval : int
put "What difficulty would you like to play on"
get level
if level = 1 then % This will put you in level 1 if you choose
delayinterval := 20 % This step is the the speed of the star(character) will be moving at
elsif level = 2 then % This will put you in level 2 if you choose it
delayinterval := 10 % This step will set the speed of the star(character) a little faster
elsif level = 3 then % This will put you in level 3 if you choose
delayinterval := 5 % This will set the star to move very fast. This is the hardest difficulty.
end if
setscreen ("graphics:650;650,offscreenonly")
var font19 := Font.New ("Algerian:20") % This step sets the font for the text
var text19 := "By - Bob Allenl" % This step enters text into the menu
var width19 := Font.Width (text19, font19 ) % This step sets the width
var font := Font.New ("Wide Latin:30") % This step sets the font for the text
var text := "Food Frenzy!!!" % This step enters the text into the menu
var width := Font.Width (text, font )
var font2 := Font.New ("Algerian:30") % This step sets the font for the text
var text2 := "CLICK TO CONTINUE!" % This step enters text into the menu
var width2 := Font.Width (text2, font2 )
var x, y, button : int
drawfillbox (0, 0, maxx, maxy div 2, 42)
% This is needed to display all the text for the menu
Font.Draw (text, round (maxx / 2 - width / 2), maxy div 2, font, red)
Font.Draw (text2, round (maxx / 4 - width2 / 4), maxy div 4, font2, red)
Font.Draw (text19, round (maxx / 6 - width19 / 6), maxy div 6, font19, red)
% This step lets the mouse be active in the menu
loop
Mouse.Where (x, y, button )
if button = 1 then
delay (200)
cls
exit when button = 1
end if
end loop
loop
Input.KeyDown (chars ) % This gives a value to the game of the keys being pressed
if chars (KEY_UP_ARROW) and y2 < maxy and ground = true then % These two lines are saying if the Up Arrow is pressed and the player is not touching the ground then make the star jump
yv + = 12
end if
if chars (KEY_LEFT_ARROW) and x1 > 0 then % These two lines are saying if the left arrow is pressed then substract 1 from the xSpeed causing the object to move left
xv - = 1
elsif chars (KEY_RIGHT_ARROW) and x2 < maxx then % These two lines are saying if the right arrow is pressed then, add to the xSpeed casuing the player to move right
xv + = 1
elsif chars (KEY_ESC) then % This step will end the program
exit
end if
if y1 > 0 then % These two lines are syaing if the player is not touching the ground then subtract the speed until the player moves down
yv - = g
% The next three lines make sure that the box does not go below the screen
elsif y1 < 0 then
yv := 0
y1 := 0
end if
% The next three lines slow down the box when moving
if xv > 0 then
xv - = 0. 5
elsif xv < 0 then
% The next five lines makes sure the box does not go off the left side of the screen and if it does moves it to the edge and stop it
xv + = 0. 5
end if
if x1 < 0 then
x1 := 0
xv := 0
% The next 5 lines do the same thing as the left side but for the right
elsif x2 > maxx then
x1 := maxx - 10
xv := 0 % Stop the player
end if
% This again does the same thing but for the top of the screen
if y2 > maxy then
y1 := maxy - 10
yv := 0 % Stop the player
end if
% The next few lines allow the player to jump
if y1 = 0 then
ground := true % Allows the jump
else
ground := false % Player cannot junp
end if
% The next steps creat movement and the size of the player
x1 + = round (xv )
y1 + = round (yv )
x2 := x1 + 20
y2 := y1 + 20
drawfilloval (foodx, foody, 5, 5, brightred)
if whatdotcolor (foodx, foody ) not= brightred then
count := count + 1
randint (foodx, 1, maxx)
randint (foody, 1, maxy)
end if
% The next two lines make the player
Draw.FillStar (x1, y1, x2, y2, black)
Draw.Star (x1 - 1, y1 - 1, x2 + 1, y2 + 1, grey)
locate (1, 1)
View.Update % Brings the player to the screen
delay (delayinterval )
cls %erases everything on the screen
end loop
|
Please specify what version of Turing you are using
Please help me and post the code. With the posted code explain how it was done please |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cezna
![](http://compsci.ca/v3/uploads/user_avatars/9406831824c097251d4bb4.gif)
|
Posted: Sun Jun 13, 2010 3:16 pm Post subject: RE:help with my game please- I need the character to eat something |
|
|
You have to ask a specific question, not just ask people to do it for you and post there solutions.
No one is going to do it for you.
Read The Rules:
http://compsci.ca/v3/viewtopic.php?t=3151 |
|
|
|
|
![](images/spacer.gif) |
turing1094
|
Posted: Sun Jun 13, 2010 4:40 pm Post subject: Re: help with my game please- I need the character to eat something |
|
|
my question is how do i get the character to eat something. I have been trying to do it for soo long and now im frustrated please help |
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Sun Jun 13, 2010 4:43 pm Post subject: Re: help with my game please- I need the character to eat something |
|
|
well depends on what u want the character to eat? and how is he going to eat it... is the food coming from the top? or is it like pacman? where he eats it from the side?
you could do something like pacman and have it that if it touches that item then it shows an eating animation and the food is moved somewhere of the map where u cant see it. or you can also use the hide feature which hides the object making it invisible to see.. specify exactly what u want to be done and how u want it to be done |
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Sun Jun 13, 2010 4:45 pm Post subject: RE:help with my game please- I need the character to eat something |
|
|
as for your game its not bad except there are several bugs that must be fixed. for example when you jump to the far right the star gets stuck and u cant move it anymore |
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Sun Jun 13, 2010 4:56 pm Post subject: RE:help with my game please- I need the character to eat something |
|
|
what you could also do is have different maps and have them over lapping and if it touches red then the oval colour is changed to white and the next map is drawn... do u get what im trying to say? or do u want me to explain it differently? |
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Sun Jun 13, 2010 5:14 pm Post subject: Re: help with my game please- I need the character to eat something |
|
|
for example you could have something like
Turing: |
var map : array 1 .. 2 of int % used to make the program shorter, easier to make more maps this way
map (1) := Pic.FileNew ("map1.bmp") % The first map of the game
map (2) := Pic.FileNew ("map2. bmp") % The second map of the game
var map1 : int := 1 % starts the map at 1 which draws the first map
var map : int := 0 % this is the coordinates of where your star will be drawn
if whatdotcolour (posx, posy ) = brightred then % if red is touched then
map1 + = 1 % map1 is now equal to 2 which later on draws map 2
map := 0 % resets the position of the map
end if
proc Drawing
if map1 = 1 then % if the map is equal to 1 it clears the screen and draws the first map
cls
Pic.Draw (map (1), map, 0, picMerge)
elsif map1 = 2 then % if the map is equal to 2 it clears the screen and draws the second map
cls
Pic.Draw (map (2), map, 0, picMerge)
% and so on
end Drawing
%Remember this is just an example you will have to change some stuff around and add some more to make it work for you.
|
|
|
|
|
|
![](images/spacer.gif) |
turing1094
|
Posted: Sun Jun 13, 2010 6:04 pm Post subject: Re: help with my game please- I need the character to eat something |
|
|
thanks for your suggestions, I want the game like pacman where you eat it sideways. I also just want the player to eat little circles, thanks. If you could please help like maybe posting what i need that would be great |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Sun Jun 13, 2010 6:13 pm Post subject: RE:help with my game please- I need the character to eat something |
|
|
i already posted an example of what u need.. im not going to write the program for you, like Cezna said earlier we are not here to do other peoples homework only to help... look at the code i provided above and try to understand what i was doing there Ps it helps that i commented it all u have to do is read it |
|
|
|
|
![](images/spacer.gif) |
turing1094
|
Posted: Sun Jun 13, 2010 9:49 pm Post subject: Re: help with my game please- I need the character to eat something |
|
|
I tried working with that and the code is not working could you please explain in more detail. thnx |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sun Jun 13, 2010 10:29 pm Post subject: RE:help with my game please- I need the character to eat something |
|
|
I will give you a tip.. However you will have to make it work correctly...
You are basically saying "if the dot isn't the color of itself then change location of the dot" this means.. 1) Unless the dots color changes, nothing will happen. 2) it doesn't even have anything to do with the players star.
So instead of your code here "if whatdotcolor (foodx, foody) not= brightred then" replace that with this, "if whatdotcolor (x1, y1) not= brightred then"
What that means is, "If players x,y is the color of the dot, then it hits and we gain a point, and respawn the dot"
The problem you have to figure out now is, Incorperating the velocity of your star. Because your star can jump at even over 12 pixels it is possible that x,y point (whatdotcolor only checks 1 pixel point its called on) making it possible for the players star to jump over it, voiding the desired effect.
If you want to stick with whatdotcolor, you have to do a check for all the pixels in the star, Along with a check for velocity.
If you have a valuable attempt and post the code and theory behind that, you will get more help. Enjoy! |
|
|
|
|
![](images/spacer.gif) |
Cezna
![](http://compsci.ca/v3/uploads/user_avatars/9406831824c097251d4bb4.gif)
|
Posted: Mon Jun 14, 2010 5:21 am Post subject: RE:help with my game please- I need the character to eat something |
|
|
Wow, monduman that was some hard spammin'
![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Monduman11
![](http://compsci.ca/v3/uploads/user_avatars/1960741284bee0b481d3b8.jpg)
|
Posted: Mon Jun 14, 2010 2:14 pm Post subject: Re: RE:help with my game please- I need the character to eat something |
|
|
Cezna @ Mon Jun 14, 2010 5:21 am wrote: Wow, monduman that was some hard spammin'
![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif)
lol is that a compliment or just a statement??? and to not let this post go to waste like token said if you have any attempts that seem right or do something close to what you want them to do post them here and you will receive more help |
|
|
|
|
![](images/spacer.gif) |
Cezna
![](http://compsci.ca/v3/uploads/user_avatars/9406831824c097251d4bb4.gif)
|
Posted: Tue Jun 15, 2010 3:02 pm Post subject: RE:help with my game please- I need the character to eat something |
|
|
It was a good-natured jab |
|
|
|
|
![](images/spacer.gif) |
|
|