Author |
Message |
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 27 Jul 2003 03:48:05 pm Post subject: |
|
|
I wonder if this would do the same:
Pause
getKey->K |
|
Back to top |
|
|
Neostar
Member
Joined: 27 Jun 2003 Posts: 105
|
Posted: 27 Jul 2003 04:25:48 pm Post subject: |
|
|
Lbl A
blah blah blah
getkey->K
If K=26:Then
blah
blah
blah
End
Goto A |
|
Back to top |
|
|
yugniht
Member
Joined: 29 May 2003 Posts: 167
|
Posted: 27 Jul 2003 04:39:14 pm Post subject: |
|
|
Arcane Wizard wrote: I wonder if this would do the same:
Pause
getKey->K
that would just wait until enter is pressed, not any key.
Also, on Alan's code, I ran it and it waited until a key was pressed, then waited for another. After that, it exited the loop, but 0 (zero) was always stored to K instead of the key I pressed. I used vti, not my actual calc. |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 28 Jul 2003 02:51:55 am Post subject: |
|
|
well, thats what it supposed to do
while u r pressing the getkey to exit, the loop has run several times in which 0 has been stored to K
i have determined that this is the best OVERALL:
Repeat A
getKey->A
End
variables can be changed
6 bytes
what ive been using since i started prgmming on the calc
fastest too |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 28 Jul 2003 03:24:24 am Post subject: |
|
|
Neostar wrote: Lbl A
blah blah blah
getkey->K
If K=26:Then
blah
blah
blah
End
Goto A
That is slow, the lbl slows it down a lot.
Also, if all you're going to do with the arrow keys is move something, use this (which is faster than an if..then..else statement) :
Xpos+Speed((K=26)-(K=24->Xpos //you can get rid of the Speed( part if you're only moving it by one
Ypos+Speed((K=34)-(K=25->Ypos
A+6((K=26)-(K=24->A
B+9((K=34)-(K=25->B
Which functions the same as:
If K=24:A-6->A
If K=26:A+6->A
If K=25:B-9->B
If K=34:B+9->B
Oh, yugniht you're right, I forgot pause only waits for enter
Last edited by Guest on 29 Jul 2003 08:29:53 am; edited 1 time in total |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 28 Jul 2003 03:28:09 am Post subject: |
|
|
Arcane Wizard wrote: A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->A
Which functions the same as:
If K=24:A-1->A
If K=26:A+1->A
If K=25:B-1->B
If K=34:B+1->B
typo:
A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->A
should be
A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->B |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 28 Jul 2003 03:54:33 am Post subject: |
|
|
Darth Android wrote: typo:
A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->A
should be
A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->B
Changed, thanks. |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 28 Jul 2003 04:19:21 am Post subject: |
|
|
Here are some things I feel should be saved from going to forum oblivion:
/*/*/*/*/*/*/*/
As for random map generator, if you want to do a maze I suggest you have a look at one of Maarten's programs called MazeRacer (which you can find on the cirrus site, or click here) which can create fully random mazes that are always solvable. If you're not going for mazes then you could just load some random values in a list like so:
For(X,1,225
RandInt(1,999->LMAP(X
End
Then, when loading the current screen you do this:
current screen->X
LMAP(X)->Rand
For(X,1,10 //10 objects in the screen
RandInt(1,95->A //random x position
RandInt(1,63->B //random y position
RandInt(1,25->C //random object
If C=1://draw tree
If C=2://draw building
//etc
End
Since it uses the same seed if you load the same screen you always have the same objects on that screen, in this code you end up with a list called LMAP with 225 screens, and you could even optimize it more so that 1 number generates an entire map of 225 screens.
Rand->LMAP(1
And then:
screen number->X
LMAP(1->Rand
For(Ø,1,X
RandInt(1,999
End
Ans->Rand
For(X,1,10 //10 objects in the screen
RandInt(1,95->A //random x position
RandInt(1,63->B //random y position
RandInt(1,25->C //random object
If C=1://draw tree
If C=2://draw building
//etc
End
Then you could always add some routines to check if it's not puttnig a tree on top of a house or a routine to create towns, instead of puttnig a building somewhere, put a flag for a town there and generate 10 buildings around it afterwards.
/*/*/*/*/*/*/*/
City:
//standard loading sequence:
current screen->X
LMAP(X)->Rand
For(X,1,30,3
RandInt(1,95->L1(X
RandInt(1,63->L1(X+1
RandInt(1,25->L1(X+2
If L1(X+2)=1:Then //a city !
For(X,X,X+12,3 //generate 4 buildings (12/3=4)
L1(X)+RandInt(-40,40->L1(X //position of building is relative to position of city
L1(X+1)+RandInt(-20,20->L1(X+1
RandInt(2,6->L1(X+2 //save a building, 2=house, 3=town center, 4=guards etc
//draw building
End
//draw object
End
Check if place is free:
Now, you could do this by checking the list but this is slow, very slow, so you could use a string if you did it on the homescreen (1 object takes 1 place) but on the graphscreen every object occupies a lot of pixels so I suggest using pixeltest.
Let's say every object has a pixel turned on right in the center (done so testing if it is free for character and other objects is easy fast) and that every object is 6*6 pixels.
current screen->X
LMAP(X)->Rand
For(X,1,10 //10 objects in the screen
Repeat Ø //generate new position until it is free
RandInt(1,15->L1(X //90/6=15, so there can be 15 objects from left to right of the screen
RandInt(1,10->L1(X+1 //60/6=10, so there can be 10 objects from top to bottom of the screen
RandInt(1,25->L1(X+2
0=Pxl-Test(6L1(X+1)+3,6L1(X)+3->Ø //check if other object has been drawn here
End
//if place is free
If L1(X+2)=1: //generate town, use pixel test again for each building.
If L1(X+2)=7: //draw tree, remember that 2 through 6 are buildings for the city and that the coordinaes stored in L1 have to be multiplied by 6 and a pixel must be on in the center of the sprite
//etc
End
/*/*/*/*/*/*/*/
Moveable and graphical character, not very good for AI and animations, they will slow down when the user moves much:
ClrDraw
AxesOff
1->Xmin
1->Ymin
95->Xmax
63->Ymax
47->A //x position of character
31->B //y pos of char
6->S
Repeat Q //until user presses clear
//draw character:
Line(A,B,A+6,B //arms
Line(A+3,B,A+3,B-3 //body
Line(A+3,B-3,A,B-6 //leg
Line(A+3,B-3,A+6,B-6 //another leg
Repeat K //wait for keypress
getKey->K
End //loop K
Text(63-B,A," " //6 spaces to erase character
A-S(K=24)+S(K=26->A //move character horizontally S pixels
B-S(K=34)+S(K=25->B //move character vertically S pixels
(K=45->Q //if user want's to quit
End //loop Q
Theory:
×set up
×loop1
×draw character
×loop2, until key is pressed
×get key pressed
×back to loop2
×erase character
×move character according to which key is pressed
×back to loop1
Good (well, better anyway, basic is just a bit slow for AI combined with graphics) for AI and animations but slower response for player:
ClrDraw
AxesOff
1->Xmin
1->Ymin
95->Xmax
63->Ymax
47->A //x position of character
31->B //y pos of char
6->S
Repeat Q //until user presses clear
getKey->K
If(K:Text(62-B,A," " //6 spaces to erase character
A-S(K=24)+S(K=26->A //move character horizontally S pixels
B-S(K=34)+S(K=25->B //move character vertically S pixels
//draw character:
Line(A,B,A+6,B [color=green]//arms
Line(A+3,B,A+3,B-3 //body
Line(A+3,B-3,A,B-6 //leg
Line(A+3,B-3,A+6,B-6 //another leg
(K=45->Q //if user want's to quit
End //loop Q
Theory:
×set up
×loop
×get key press
×if key is pressed, erase character
×move character according to key pressed
×draw character
×back to loop
Collision detection (don't walk through things):
Repeat Q
getKey->K
If(K:Text(62-B,A," " //6 spaces to erase character
//calculate new position
A-S(K=24)+S(K=26->C
B-S(K=34)+S(K=25->D
//check if place is free, using PxlTest(Y,X
0=PxlTest(62-D+.5S,C+.5S->Ø //only checks middle of new pos, so when you're drawing a wall you should make it S pixels wide or, if you want smaller walls, add more PxlTests
A+Ø(C-A->A //move character horizontaly if new position is free
B+Ø(D-B->B //move character vertically if new position is free
//draw character:
Line(A,B,A+6,B [color=green]//arms
Line(A+3,B,A+3,B-3 //body
Line(A+3,B-3,A,B-6 //leg
Line(A+3,B-3,A+6,B-6 //another leg
(K=45->Q //if user want's to quit
End //loop
Theory:
×set up
×loop
×get key pressed
×if key pressed, erase character
×calculate new position of character
×check if this new position is free with PxlTest(Ypixel,Xpixel
×if so, move character
×draw character
×back to loop
/*/*/*/*/*/*/*/
Here's the sprite i always use:
001100
111111
001100
010010
010010
Then I could add shoes like so:
001100
111111
001100
010010
110011
Or a hat like so:
000010
001110
111111
001100
111111
001100
010010
010010
Or a staff like so:
1001100
1111111
1001100
1010010
1010010
Or a robe like so:
001100
111111
001100
010010
111111
The neat thing is, they can all be combined, so I just have some extra line( or pt-on( statements after drawing that first sprite and it adds what the character has (a robe, hat, shoes, staff, etc.) This way the player can actually see the equipment (well, most of it anyway, you wouldn't be able to tell the difference between a staff of spellcasting and a staff of asskicking +6 though) of his/her character.
/*/*/*/*/*/*/*/
Repeat Q or Ø
getKey->K
If K:Pxl-Off(B,A
A+(K=26)-(K=24->C
B+(K=34)-(K=25->D
0=Pxl-Test(D,C->Ø
A+Ø(C-A->A
B+Ø(D-B->D
(K=45->Q
End
If Ø:Then //player hit a pixel
//check if building has to be loaded or maybe battle sequence
End
/*/*/*/*/*/*/*/ |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 28 Jul 2003 04:22:46 am Post subject: |
|
|
well, there's no point in errors
especially id they confuse someone new to programming! |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 28 Jul 2003 05:25:05 am Post subject: |
|
|
That's why I thanked you. |
|
Back to top |
|
|
omni
Member
Joined: 14 Jun 2003 Posts: 115
|
Posted: 28 Jul 2003 08:55:57 am Post subject: |
|
|
How about IS( and DS(, what do they do?
(I've never actually used IS( and DS( come to think of it.) |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 28 Jul 2003 09:51:30 am Post subject: |
|
|
IS>(variable,value)
Increases variable by one and checks if the result is > than value, if so it skips the following line.
6->A
IS>(A,6
Disp "not > 6
Disp "> 6
Will display:
> 6
DS<(variable,value)
Decreases variable by one and checks if the result is < than value, if so it skips the following line.
6->A
DS<(A,6
Disp "> 6
Disp "not < 6
Will display:
not > 6
Never used it either.
Last edited by Guest on 29 Jul 2003 08:40:32 am; edited 1 time in total |
|
Back to top |
|
|
omni
Member
Joined: 14 Jun 2003 Posts: 115
|
Posted: 28 Jul 2003 10:02:52 am Post subject: |
|
|
So its somewhat like an If then statement |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 28 Jul 2003 12:56:02 pm Post subject: |
|
|
also ur if statments at the end only add and subtract 1... just fyi |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 28 Jul 2003 01:06:29 pm Post subject: |
|
|
somewhat, but less useful... no one really knows how to use them... i do though and so does Arcane apparently |
|
Back to top |
|
|
yugniht
Member
Joined: 29 May 2003 Posts: 167
|
Posted: 28 Jul 2003 04:31:09 pm Post subject: |
|
|
Darth Android wrote: well, thats what it supposed to do
yes, it does wait for two keys to be pressed, but my point was that it always stores zero to K. So, what's the poing of having the ->K if it doesn't work??? |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 28 Jul 2003 10:46:34 pm Post subject: |
|
|
many ppl know how to use them, but never use them. if anyone finds a prgm that uses them, tell me |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 29 Jul 2003 01:00:41 am Post subject: |
|
|
Adm.Wiggin wrote: also ur if statments at the end only add and subtract 1... just fyi
I have no idea what you're talking about.
And I did say it functioned the same way, not that it did the same thing.
Last edited by Guest on 29 Jul 2003 01:01:35 am; edited 1 time in total |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 29 Jul 2003 01:19:34 am Post subject: |
|
|
Well, they can be used instead of if..then..else statements that only have 1 line at the then part and 1 line at the else part:
If X > 16
Then
Disp "X > 16
Else
Disp "not X > 16
End
IS>(X,16
Disp "not X > 16
Disp "X > 16 |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 29 Jul 2003 07:28:21 am Post subject: |
|
|
Adm.Wiggin wrote: also ur if statments at the end only add and subtract 1... just fyi
he meant this:
A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->B
usually, most ppl do this:
A+6(K=26)-6(K=24->A
B+9(K=26)-9(K=24->B
but the top one has the 9( and the 6( in front of them, which save no space. im not sure if the speed is the same, but the siz is exactly the same for both. also:
A+6((K=26)-(K=24->A
B+9((K=26)-(K=24->B
should be
A+6((K=26)-(K=24->A
B+9((K=34)-(K=25->B
unless im mistaken |
|
Back to top |
|
|
|