Challenge
Author |
Message |
Flikerator
|
Posted: Mon May 30, 2005 10:50 am Post subject: Challenge |
|
|
I made this in 15 mins, anyone wanna try and fix it? All you have to do is keep the code reletivly the same and it must work properly. The problem is that when you go to the edge of the map it stops and there is no way to get away because it keeps making you stay there.
code: | View.Set ("offscreenonly")
var chars : array char of boolean
var playermov : int := 3
type Player :
record
x : real
y : real
end record
var players : array 1 .. 1 of Player
players (1).x := 50
players (1).y := 50
var obst : boolean := false
procedure obstacle (n : int)
if players (n).x + playermov + 7 > maxx then
obst := true
elsif players (n).x - playermov - 7 < 0 then
obst := true
elsif players (n).y + playermov + 7 > maxy then
obst := true
elsif players (n).y - playermov - 7 < 0 then
obst := true
end if
end obstacle
procedure player1
obstacle (1)
if chars ('w') and obst = false then
players (1).y += playermov
end if
if chars ('a') and obst = false then
players (1).x -= playermov
end if
if chars ('s') and obst = false then
players (1).y -= playermov
end if
if chars ('d') and obst = false then
players (1).x += playermov
end if
Draw.FillOval (round (players (1).x), round (players (1).y), 5, 5, red)
end player1
loop
Input.KeyDown (chars)
player1
View.Update
cls
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
StarGateSG-1
![](http://img61.imageshack.us/img61/4417/jesushulk2sq.gif)
|
Posted: Mon May 30, 2005 1:16 pm Post subject: (No subject) |
|
|
What doers this program do?
Just move the ball on the screen? |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Mon May 30, 2005 1:32 pm Post subject: (No subject) |
|
|
Just put restrictions on the if statements where it wont go anywhere if its >, < or whatever.
code: | View.Set ("offscreenonly")
var chars : array char of boolean
var playermov : int := 3
type Player :
record
x : real
y : real
end record
var players : array 1 .. 1 of Player
players (1).x := 50
players (1).y := 50
procedure player1
if chars ('w') and players (1).y < maxy - 7 then
players (1).y += playermov
end if
if chars ('a') and players (1).x > 7 then
players (1).x -= playermov
end if
if chars ('s') and players (1).y > 7 then
players (1).y -= playermov
end if
if chars ('d') and players (1).x < maxx - 7 then
players (1).x += playermov
end if
Draw.FillOval (round (players (1).x), round (players (1).y), 5, 5, red)
end player1
loop
Input.KeyDown (chars)
player1
View.Update
cls
end loop |
|
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Mon May 30, 2005 3:12 pm Post subject: (No subject) |
|
|
Just out of curiosity, i dont think you need record or arrays for this thing. Only the chars array adn that should be it ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
StarGateSG-1
![](http://img61.imageshack.us/img61/4417/jesushulk2sq.gif)
|
Posted: Mon May 30, 2005 4:04 pm Post subject: (No subject) |
|
|
That is what threw me off, I don;t get what he did, if he is just trying to move dot on the screen? |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon May 30, 2005 4:10 pm Post subject: (No subject) |
|
|
MysticVegeta wrote: Just out of curiosity, i dont think you need record or arrays for this thing. Only the chars array adn that should be it ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif)
We don't actually need classes either. Or functions. We could do all the work for the computer, so that it only has to go linearly and does not have to expand the code you give it. But that makes it harder on us.
All I'm saying is this: Just because you don't have to use something, it does not mean you should not use it.
Also, you're sig is a.) long and b.) wrong. The infine number would be of infinately small (x -> 0) measurements. This you did not take into account. So it's infinity * infinately close to 0 which turns out to be some finite number. Namely 10. ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
StarGateSG-1
![](http://img61.imageshack.us/img61/4417/jesushulk2sq.gif)
|
Posted: Mon May 30, 2005 4:15 pm Post subject: (No subject) |
|
|
That makes no sense to me at all, maybe I have a headache but still ![Shocked Shocked](http://compsci.ca/v3/images/smiles/icon_eek.gif) |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Mon May 30, 2005 5:05 pm Post subject: (No subject) |
|
|
Cervantes wrote:
Just because you don't have to use something, it does not mean you should not use it.
Dam, our teacher taught us "KISS" Keep it Simple Student. If i use it, thats like -10 for redundancy. (hope i spelled it right lol)
Cervantes wrote:
Also, you're sig is a.) long and b.) wrong.
Hey they rhyme lol.
Cervantes wrote:
The infine number would be of infinately small (x -> 0) measurements.
.0000000000000001 != 0
.0000000000000000000000001 != 0
.0000000000000000000000000000000000000001 != 0
Fact: People researched over this problem for 30 years
Solution: People solve this problem by taking a least unit called a "quantum" and thats indivisible. You drive 1 quantum every x second.
I dont know why they made it and dont know what it does because i am 15
But i read it somewhere, i think it was mathematica 5.1 or somethin
[/quote] |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon May 30, 2005 5:21 pm Post subject: (No subject) |
|
|
Personally, I feel that zero decimal an infinate number of zeroes followed by a one is equal to zero.
MysticVegeta wrote: Solution: People solve this problem by taking a least unit called a "quantum" and thats indivisible. You drive 1 quantum every x second.
We're talking about math here, not physics. Besides, a quantum is not a measurement of distance. And saying that travelling a distance less than the width of one quantum (which is what I think you're getting at) must be wrong, be cause singularities (big bang, black holes) exist (correct?).
MysticVegeta wrote:
dont know what it does because i am 15
![Sad Sad](http://compsci.ca/v3/images/smiles/icon_sad.gif)
That should not make any difference. Never let your age deter you from learning something. |
|
|
|
|
![](images/spacer.gif) |
lyam_kaskade
![](http://www.linux-squad.com/albumphoto/linuxwallpapers/thumbnails/tn_born2frag.jpg)
|
Posted: Mon May 30, 2005 6:25 pm Post subject: (No subject) |
|
|
In any case, mathematics aside, we still know someone can drive 10km in 1 hour. (You can't, though, because you're only 15 (unless you live in Alberta or some other wierd place)). |
|
|
|
|
![](images/spacer.gif) |
|
|