Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Challenge
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Flikerator




PostPosted: 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

Sponsor
Sponsor
Sponsor
sponsor
StarGateSG-1




PostPosted: Mon May 30, 2005 1:16 pm   Post subject: (No subject)

What doers this program do?
Just move the ball on the screen?
jamonathin




PostPosted: 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
MysticVegeta




PostPosted: 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
StarGateSG-1




PostPosted: 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?
Cervantes




PostPosted: 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

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
StarGateSG-1




PostPosted: 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
MysticVegeta




PostPosted: 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
Sad But i read it somewhere, i think it was mathematica 5.1 or somethin
[/quote]
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: 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

That should not make any difference. Never let your age deter you from learning something.
lyam_kaskade




PostPosted: 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)).
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: