Qbasicnews.com
February 22, 2020, 07:31:29 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Drawing?  (Read 7198 times)
arpgme
Member
*
Posts: 69


« on: July 15, 2005, 08:04:53 PM »

I already know how can I draw in Quick Basic  but how can I let
the person draw in the program?
Logged

~~~~~~~~~~~~~~~~~~~~~~~~~~

I love Quick Basic better then Python...

And Python is new.........

Oh yea catch ARPGME
Anonymous
Guest
« Reply #1 on: July 15, 2005, 08:27:29 PM »

think about it like this.

the keyboard and mouse (but mostly keyb) in qb is the only link you have between your executable program and the user.

so what you need to do is create a program that loops, and gets keyboard input every loop.

and then you need to "translate" that input into the execution of code.

so say we got a dot at 30, 40 on the screen

change that into vars, dotx, doty and fill em:


Quote
dotx = 30
doty = 40

pset ( dotx, doty ), 15 'puts the dot there as a white dot



so heres pseudo code (this next part wont run, but its the idea you must grasp)


Code:
loop  ------------------------------------------------|
                                                      |
if presskey( "up" ) then gosub upthing                |
                                                      |
                                                      |
pset ( dotx, doty ), 15                               |
                                                      |
loop until presskey( "escape" )-----------------------|


end


upthing:

doty = doty - 1

return


hope it makes sense, i can do a bit more later if time allows

before the big party tonight ;D (anyone from nw illinois here? :P:P)

edit: i'll add a version that runs:

Code:
screen 13 'graphics!

dotx = 30
doty = 40

do

keyin$ = inkey$ 'grab keyboard input
                                                   
if keyin$ = chr(0) + "H"  then gosub upthing
'Don't worry if this seems weird, it's basically just a qb hack to get the arrows.
'this is the up arrow (duh..)
                                             
                                             
pset ( dotx, doty ), 15  
                                                   
loop until keyin$ = chr$(27) 'the code for the escape key

end


upthing:

if doty > -1 then 'add check to keep the dot from going off screen
  doty = doty - 1

end if

return


youll notice, it draws a line. but in reality, this isnt drawing a line, its drawing single dots, the old ones are just never erased
Logged
arpgme
Member
*
Posts: 69


« Reply #2 on: July 15, 2005, 08:32:34 PM »

Woah! you have to remember I am a newbie at all of this stuff.[/b]
Logged

~~~~~~~~~~~~~~~~~~~~~~~~~~

I love Quick Basic better then Python...

And Python is new.........

Oh yea catch ARPGME
rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #3 on: July 15, 2005, 08:53:05 PM »

Quote from: "arpgme"
Woah! you have to remember I am a newbie at all of this stuff.[/b]

I'm afraid it seems to me like everything you are trying to do is a bit above newbie. This like getting INPUT from a user, but taking it to the next level with graphics.

I'll try to explain what each part does.
Code:
screen 13 'this is required for you to draw at all, in case you didn't know. this is the recommended screen for creating games in QB

dotx = 30 'this is the starting horizontal position on the screen
doty = 40 'this is the starting vertical position on the screen

do

keyin$ = inkey$ 'grab keyboard input
                                                   
if keyin$ = chr$(0) + "H"  then gosub upthing
'if the Up arrow key is pressed, then your program's flow changes to the "upthing" sub (toward the end)
                                             
                                             
pset ( dotx, doty ), 15 'this draws a white dot at the specified coordinates
                                                   
loop until keyin$ = chr$(27) ' this just says that the program should end if the escape key is pressed

end
'ends the program; required unless you want to go through the "upthing" sub for no reason


upthing:

if doty > -1 then 'add check to keep the dot from going off screen
  doty = doty - 1 'make the dot move up one pixel

end if

return 'continue with the program at the point after the flow was changed


I'm not sure if it can get any more BASIC than that (pun intended). . .
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
arpgme
Member
*
Posts: 69


« Reply #4 on: July 15, 2005, 09:15:32 PM »

Your right, what should I pretice making on newbie level? :Huh:
Logged

~~~~~~~~~~~~~~~~~~~~~~~~~~

I love Quick Basic better then Python...

And Python is new.........

Oh yea catch ARPGME
Deleter
Na_th_an
*****
Posts: 1293



WWW
« Reply #5 on: July 15, 2005, 09:24:38 PM »

program controlled graphics Smiley
Logged

MystikShadows
Ancient Guru
****
Posts: 542



WWW
« Reply #6 on: July 15, 2005, 09:42:52 PM »

Hi arpgme,

You can go here:
http://www.petesqbsite.com/sections/tutorials/othertuts.shtml#GameDesign

and look for a section called Vic's Tutorials  (about 1/3 down the whole page)

there's 21 tutorials, they're concise and quick to learn and they're all about game programming.  I'd say it's a good place to start :-)
Logged

hen they say it can't be done, THAT's when they call me ;-).




need hosting:  http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Pyrokid
Wandering Guru
***
Posts: 355



WWW
« Reply #7 on: July 21, 2005, 02:11:50 AM »

ok i know this topic is dead but i will warn other readers who read this. I know i am still a bit of a newbie but still i would warn others to stay away from vics tuts they can be VERY confusing try a dif tut on petes site.
Sory if i offended vic
Logged

his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless  effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
arpgme
Member
*
Posts: 69


« Reply #8 on: July 21, 2005, 02:09:18 PM »

THat JUST SHOWS A DOT!   I want them to draw!
Logged

~~~~~~~~~~~~~~~~~~~~~~~~~~

I love Quick Basic better then Python...

And Python is new.........

Oh yea catch ARPGME
Sumo Jo
Been there, done that
*****
Posts: 1244



WWW
« Reply #9 on: July 21, 2005, 09:53:47 PM »

Quote from: "arpgme"
THat JUST SHOWS A DOT!   I want them to draw!


You have to learn basics to do the advanced.
Logged

url=http://fileanchor.com]FileAnchor[/url] - ImageAnchor - FBTK - QbasicNews - VPlanet - Various
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #10 on: July 21, 2005, 11:30:44 PM »

Yeah, it's called pixel art. Here's something to practice with. Maybe  try making it more advanced. Wink


Code:
Screen 13


Do
  Inky$=Inkey$  
    If Inky$="4" Then X=X-1
    If Inky$="6" Then X=X+1
    If Inky$="8" Then Y=Y-1
    If Inky$="2" Then Y=Y+1

    If X<0 Then X=0
    if X>319 Then X=319
    If Y<0 Then Y=0
    if Y>199 Then Y=199
   
    Colour = Colour+1
    If Colour>255 Then Colour = 1
    Pset(X,Y),Colour
Loop until Inky$=Chr$(27)
Logged
Dio
I hold this place together
*****
Posts: 874



« Reply #11 on: July 22, 2005, 12:41:50 AM »

Quote from: "Dr_Davenstein"
Yeah, it's called pixel art. Here's something to practice with. Maybe  try making it more advanced. Wink


Code:
Screen 13


Do
  Inky$=Inkey$  
    If Inky$="4" Then X=X-1: colour = colour + 1
    If Inky$="6" Then X=X+1: colour = colour + 1
    If Inky$="8" Then Y=Y-1: colour = colour + 1
    If Inky$="2" Then Y=Y+1: colour = colour + 1

    If X<0 Then X=0
    if X>319 Then X=319
    If Y<0 Then Y=0
    if Y>199 Then Y=199
   
    If Colour>255 Then Colour = 1
    Pset(X,Y),Colour
Loop until Inky$=Chr$(27)


i like this better Wink
------------------------------------
edit: hey, look at what i did:

[syntax="qbasic"]SCREEN 13
FOR y = 0 TO 199
SELECT CASE dir
  CASE 0
    FOR x = 0 TO 319
      c = c + 1: IF c = 256 THEN c = 16
      PSET (x, y), c
    NEXT
    dir = 1
  CASE 1
    FOR x = 319 TO 0 STEP -1
      c = c + 1: IF c = 256 THEN c = 16
      PSET (x, y), c
    NEXT
    dir = 0
END SELECT
c = c + y
DO
IF c > 255 THEN c = c - 255
LOOP UNTIL c < 256
NEXT
SLEEP[/syntax]
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Pyrokid
Wandering Guru
***
Posts: 355



WWW
« Reply #12 on: July 22, 2005, 06:28:18 PM »

Pixel art eh? Check this:


Code:

SCREEN 12
PRINT "Press space to continue to the next design"
PRINT "Press Esc to quit"
DO: LOOP WHILE INKEY$ = ""
1
CLS b
x = 0: y = 0
xadj = 1: yadj = 1

xchg = INT(RND * 20)
ychg = INT(RND * 20)
negx = INT(RND * -20)
negy = INT(RND * -20)

DO
a$ = INKEY$
color1 = INT(RND * 16)
PSET (x, y), color1

IF x <= 0 THEN xadj = xchg
IF x >= 640 THEN xadj = negx
IF y <= 0 THEN yadj = ychg
IF y >= 480 THEN yadj = negy
x = x + xadj: y = y + yadj
IF a$ = CHR$(27) THEN END
IF a$ = " " THEN EXIT DO
LOOP
GOTO 1

Logged

his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless  effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #13 on: July 22, 2005, 06:54:21 PM »

Guys, I was just trying to show him the most simple way to allow a user to draw on the screen, not start a competition.  :lol:
Logged
arpgme
Member
*
Posts: 69


« Reply #14 on: July 22, 2005, 08:23:56 PM »

Thanx
Logged

~~~~~~~~~~~~~~~~~~~~~~~~~~

I love Quick Basic better then Python...

And Python is new.........

Oh yea catch ARPGME
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!