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

Username:   Password: 
 RegisterRegister   
 help with title screen and border with a keydownsketch
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tg851




PostPosted: Mon Oct 17, 2011 10:22 am   Post subject: help with title screen and border with a keydownsketch

ive been working on a little peice of code resulitng from a debug that im trying to make into a simple etch-a-sketch based around keyinput.down and am trying to add a title scren with instructions and a border to prevent the brush from going of-screen as well as some general constructive criticism.its currently more of a stupid dwarf trick than an actual program as well as those 2 things causing me a good amount of fun(of the dwarf fortress variety)for the past week, I've finally gotten to posing here for help.
also credits to tony for the basic movement code.
version is 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Mon Oct 17, 2011 4:40 pm   Post subject: Re: help with title screen and border with a keydownsketch

Well the title screen can be easy if you only want it at the start. Just put some code before you start your loop and then put a line like

Turing:

var uselessString : string(1) % put this in with variable I guess

% Some code for a title screen

put "Press any key to begin."
getch (uselessString)

% Start loop
loop
% ...


As for the border move the setscreen line to the beginning to get something like this

Turing:

var x, y, l, w, c : int
setscreen ("graphics:1000;660,nobuttonbar")
% Your border limits
const minX := 20
const maxX := maxx - 20
const minY := 20
const maxY := maxy - 20

% More variable stuff


Draw.Box (minX, minY, maxX, maxY, black)
loop


% All the stuff up from Input.KeyDown to the Delete key stuff

if x - w < minX then
        x := minX + w
    elsif x + w > maxX then
        x := maxX - w
    end if

    if y - l < minY then
        y := minY + l
    elsif y + l > maxY then
        y := maxY - l
    end if

     drawfilloval (x, y, l, w, c)

     % Rest of the code as usual

Aange10




PostPosted: Mon Oct 17, 2011 4:41 pm   Post subject: Re: help with title screen and border with a keydownsketch

Ah, well first off let me tell you that you've come to the right place for help. Though I do recommend you fill out the default headers, as it helps us to help you more. Since I don't clearly know what you need help with, I'll help you with the three things I think you do.

tg851 wrote:

and am trying to add a title screen with instructions and a border to prevent the brush from going of-screen as well as some general constructive criticism.


General Criticism

Variables should let us know what they are manipulating.
Turing:

var x,y,l,w,c : int

I'm not sure what x, y, l, w, or c stands for at first glance. You should extend the names. For example x could be brushX or brush_x.


Adding a Title Screen

The easiest way to go about this is to ask yourself what you want to happen. I suggest you read
The Basics for trying to output text to the screen using put. Also if you'd like to experiment with making the program look a better you can check out Basic Graphics. It will teach you about Font.Draw.

Borders

If you are looking to draw a border on the screen, you will probably be using the drawline command. Also if you are looking to physically set up borders for the circle, i suggest you read Collision detection.


~~~~~~~~~~

If after you have read those pages, you still need help, don't hesitate to ask. --- And there are some shortcuts to making the border. Ones that don't involve so much math(:
tg851




PostPosted: Tue Oct 18, 2011 10:16 am   Post subject: Re: help with title screen and border with a keydownsketch

thanks,and its the physical border to stop the brush from going off the screen that's what Im looking for,the vars I have to use are usaly 1 character abbreviations,these ones stood for
x=x position
y=y position
l=length
w=width
c=colour
these are my school standard variables for everything,not mine(too ocd for something so unobvious)
the problem was when it when into the program the text would stay up and not go away and for collisions it seems to only work about half the time and the other half the time the brush phases through.
Aange10




PostPosted: Tue Oct 18, 2011 4:48 pm   Post subject: Re: help with title screen and border with a keydownsketch

tg851 @ 18/10/2011, 9:16 am wrote:

the problem was when it when into the program the text would stay up and not go away


How does one get rid of text/ clear the screen?

tg851 @ 18/10/2011, 9:16 am wrote:

and for collisions it seems to only work about half the time and the other half the time the brush phases through.


Well that would probably be a mishap on your math, but no worries. There are simpler ways of doing it. For example if you have

Turing:

var key_press : array char of boolean
% Movement
if key_press (KEY_RIGHT_ARROW) = true then
    x += 1
end if


What would be an easy way of making sure the character doesn't go past the screen? [Highlight below to see the answer]



var key_press : array char of boolean
% Movement
if key_press (KEY_RIGHT_ARROW) = true and x < maxx then
x += 1
end if
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  [ 5 Posts ]
Jump to:   


Style:  
Search: