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

Username:   Password: 
 RegisterRegister   
 Basic car movement game thing.
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
recneps




PostPosted: Sat Jan 17, 2004 9:40 pm   Post subject: Basic car movement game thing.

This shows how to make a car move around using angles and stuff. more explained in code Smile (well, 2 lines of text explains it.)
bits are nice if you use this (i know SOMEONE will try to use this as their own for final prog Smile )



test.zip
 Description:
Car movement with angles. Crappy car pic included! :D

Download
 Filename:  test.zip
 Filesize:  1.54 KB
 Downloaded:  1181 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
sport




PostPosted: Sat Jan 17, 2004 10:04 pm   Post subject: Useful Code

Excellent Program. It will be put to good use.
DanShadow




PostPosted: Sat Jan 17, 2004 10:10 pm   Post subject: (No subject)

hm...pretty nice, I remember doing a program similar to this before. Although, I wish you would have developed your own code without taking some from another program, but have some bits anyway. Smile
+5 Bits
Leiak




PostPosted: Sat Jan 17, 2004 11:22 pm   Post subject: (No subject)

i cant get it to work on my program can someone direct me towards a url that i can download a better turing program plz and thankie
recneps




PostPosted: Sun Jan 18, 2004 4:26 pm   Post subject: (No subject)

i would, but i have gr 10 math next sem, and i dunno how i would make it move forward at that angle:) (i only borrowed 2 lines Very Happy)
recneps




PostPosted: Sun Jan 18, 2004 4:27 pm   Post subject: (No subject)

and about the turing download, go to compsci main page, theres a linkto turing 4.0.5 update
shorthair




PostPosted: Sun Jan 18, 2004 4:45 pm   Post subject: (No subject)

Rolling Eyes do you mind if i steal like 20 lines of that code for a game of mine , Rolling Eyes il give you a bit
recneps




PostPosted: Wed Jan 21, 2004 4:02 pm   Post subject: (No subject)

doesnt matter Very Happy (i borrowed 2 lines anyway Very Happy)
Sponsor
Sponsor
Sponsor
sponsor
netninja




PostPosted: Wed Feb 11, 2004 10:35 pm   Post subject: (No subject)

The car was really screwed up so i looked over the code, and i found that you put setscreen ("graphics:nooffscreenonly") instead of setscreen ("offscreenonly").

Once i fixed that, the choppy graphics dissappeared Very Happy Did anyone else get that flashing car instead of a nice solid car?
Maverick




PostPosted: Wed Feb 11, 2004 10:42 pm   Post subject: (No subject)

hey really sweet prog man
GUI.GetScrollBarWidth : i




PostPosted: Fri Feb 13, 2004 5:56 pm   Post subject: (No subject)

super cool. cars r fun. but the graphics r choppy
rizzix




PostPosted: Sun Feb 15, 2004 9:59 pm   Post subject: (No subject)

hehe wanna fix the graphics?

here's the modified code using my library..
code:

include "stdlib.t"

%Made by receneps. Yay.
%Some code taken from spacegame example (but i made it easier to understand :D)
%Use up, left and right to move. Esc to quit.

%All variable names are self explanatory :)
const maxframerate : int := 30
const numships : int := 36
var keys : array char of boolean
const up : char := chr (200)
const left : char := chr (203)
const right : char := chr (205)
const esc : char := chr (27)
const shiprad : int := 19
const shipfrad : int := 23
var ship : array 0 .. 35 of int
var shipf : array 0 .. 35 of int
var angle : int
var x, y, dx, dy : real


procedure drawscreen
    %draw the ship with the appropriate angle.

    GFXDrawRefreshPic (ship (angle), round (x) - shiprad, round (y) - shiprad)

    %Pic.Draw (ship (angle), round (x) - shiprad, round (y) - shiprad, picMerge)
    %View.Update
end drawscreen

drawfillbox (0, 0, maxx, maxy, black)
setscreen ("offscreenonly")
ship (0) := Pic.FileNew ("crappycar.bmp")
Pic.SetTransparentColour (ship (0), black)

for i : 1 .. numships - 1 %make all frames of the ship.(-1 because the 0 is already set.)
    ship (i) := Pic.Rotate (ship (0), i * (360 div numships), shiprad, shiprad)
end for
angle := 0
x := maxx div 2
y := maxy div 2
dx := 0
dy := 0
colourback (black)
loop %get key info
    Input.KeyDown (keys)
    if keys (up) then
        dx -= sind (angle * 10) %dont ask me, only gr 9 math (gr 10 next sem!)
        dy += cosd (angle * 10) %got from spacegame exmaple :D lol
    end if
    if keys (right) then %rotate if right
        angle := (angle - 1) mod numships
        delay (25)
    end if
    if keys (left) then %rotate if left
        angle := (angle + 1) mod numships
        delay (25)
    end if
    if keys (esc) then %exit when hit esc
        exit
    end if
    dx := min (max (dx, -20), 20) %Set "speed limit"
    dy := min (max (dy, -20), 20)
    x += dx
    y += dy
    if x > maxx then
        x := maxx %keep car in bounds for x
    end if
    if x < 0 then
        x := 0
    end if
    if y > maxy then
        y := maxy %keep car in bounds for y
    end if
    if y < 0 then
        y := 0
    end if
    drawscreen
    dx := 0
    dy := 0
end loop



and attached is the library...



stdlib.t
 Description:
just part of it .. (include only tested stuff)

Download
 Filename:  stdlib.t
 Filesize:  13.73 KB
 Downloaded:  392 Time(s)

Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: