Drawing question
Moderator: MaxCoderz Staff
Drawing question
Hey, Im just curious how you guys draw game maps and the active objects like the player.
They way I do it is that before the level starts, it draws the matrix line by line. Then it draws the player. I am having a problem with the player drawing part. I use the output command btw. So, when the player presses a button, I have it so sets the position to " " and updates the output with the new X and Y. Sometimes, the " " goes over the already drawn level and that is bad. D:
How should I draw my character and map?
They way I do it is that before the level starts, it draws the matrix line by line. Then it draws the player. I am having a problem with the player drawing part. I use the output command btw. So, when the player presses a button, I have it so sets the position to " " and updates the output with the new X and Y. Sometimes, the " " goes over the already drawn level and that is bad. D:
How should I draw my character and map?
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
is this assembly or basic?
in basic I would use xLIB (use real(2 for the map and real(1 for the player - sprite)
in assembly its even easier, just draw the map (wouldn't use a floating-pointing matrix for this, you won't need 9 bytes for each entry) and then draw the play over it, and don't forget to copy your buffer to the LCD
in basic I would use xLIB (use real(2 for the map and real(1 for the player - sprite)
in assembly its even easier, just draw the map (wouldn't use a floating-pointing matrix for this, you won't need 9 bytes for each entry) and then draw the play over it, and don't forget to copy your buffer to the LCD
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Also there is a program called "bytedraw" at ticalc.org that draws 8 pixels at once, which makes any drawing routine 8 times as fast as it would have been with pixelOn or pixelOff.
But xLIB is way better for tilemaps, bytedraw is good for drawing things that are stored as "picture" in lists/strings/matrices
But xLIB is way better for tilemaps, bytedraw is good for drawing things that are stored as "picture" in lists/strings/matrices
" " and output... I'm assuming this is text based?... To save the next square, you know you can't read the screen and a location and put it as a string or whatever.. The method that I did for replacement was when the text thingy moves, the square it's on is checked on the matrix with whatever value it contains, then the appropiate lil text thing is drawn on the (A,B) the current location of the "character" before its moved in its direction.
I hope this was what your looking for?
I hope this was what your looking for?
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Not everyone uses xlib...Especially when you just start programming..
And drawing letters on a picture is easier?! You don't draw letters if you can draw cool images. It's also a lot easier to go through two for-loops and output lil' characters to the screen, corresponding to the maxtrix. This wouldn't work if he was scrolling, then xlib would pwn.. But then you wouldn't be moving the center drawing if it was scrolling (except at edges..)..It would be in the center.
And drawing letters on a picture is easier?! You don't draw letters if you can draw cool images. It's also a lot easier to go through two for-loops and output lil' characters to the screen, corresponding to the maxtrix. This wouldn't work if he was scrolling, then xlib would pwn.. But then you wouldn't be moving the center drawing if it was scrolling (except at edges..)..It would be in the center.
Yes, Im using Basic. And yes its text based ;P
I clear the player's position then move him THEN draw him again. Pretty simple.
[quote=cjgone]
" " and output... I'm assuming this is text based?... To save the next square, you know you can't read the screen and a location and put it as a string or whatever.. The method that I did for replacement was when the text thingy moves, the square it's on is checked on the matrix with whatever value it contains, then the appropiate lil text thing is drawn on the (A,B) the current location of the "character" before its moved in its direction.
[/quote]
I was thinking of something similar but I worried that it might take too long to execute. Have you tested?
Btw, I was thinking of trying xlib but Im pretty new, maybe some day.
Thanks everyone that helped! I will try to put all of your tips to good use.
I clear the player's position then move him THEN draw him again. Pretty simple.
[quote=cjgone]
" " and output... I'm assuming this is text based?... To save the next square, you know you can't read the screen and a location and put it as a string or whatever.. The method that I did for replacement was when the text thingy moves, the square it's on is checked on the matrix with whatever value it contains, then the appropiate lil text thing is drawn on the (A,B) the current location of the "character" before its moved in its direction.
[/quote]
I was thinking of something similar but I worried that it might take too long to execute. Have you tested?
Btw, I was thinking of trying xlib but Im pretty new, maybe some day.
Thanks everyone that helped! I will try to put all of your tips to good use.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Using the 'non-xlib' way, it's not that slow actually (Do not try smooth-scrolling, does not work [slow]).
(I'm not known for efficiency.. Nor do I care..It's BASIC..
Pretty much:
This thing works nicely for level editing too.. You can't make platformer games (obviously).. maybe an rpg... Go with xlib
Oh, assembly is also a good choice..
(I'm not known for efficiency.. Nor do I care..It's BASIC..
Pretty much:
Code: Select all
For a,1,8
For b,1,16
If [A](a,b) = 1
then
Ouput(A,B,"X"
end
If [A](a,b) = 2
then
Output(A,B,"O"
end
end
end
Location1 -> a ;aka x and y
Location2 -> b
output(a,b,"?" ; your main character -_-
While 1
getkey -> z
if z = 24 and B =/ 1 ; not equal..
then
;------- This is the redraw matrix crap
If [A](a,b) = 1
then
Ouput(A,B,"x"
end
If [A](a,b) = 2
then
Output(A,B,"O"
end
;------------ pretty much
B-1 -> B
output(a,b"?" ;; yep creative.. '?' is your character...
end
end
Oh, assembly is also a good choice..
Thanks for the idea.
Ill try xlib some day. At the moment Im making a metroid platformer. At the moment I have gravity down, secure movement in all areas of screen (none of the errors if it checks for non existant vars in a matrix), shooting in both directions. I had opening doors but my calc crashed or something and all ram cleared. Luckily I had pretty recent backups ^.^;
Is it safe to use "while" loops within "while" loops?
By the way, how do you put comments into your code? other languages that I write in use two forward slashes followed by a comment.
It would really help to keep tabs and show what does what.
Lastly, I cant get the PC program editor to work for some reason, I need it so I can make the level matrix values easier. Is there any way to get it working or any external editors? It says something about .net being needed. If it needs a windows update, no can do -_- I supposedly have a pirated windows.
Ill try xlib some day. At the moment Im making a metroid platformer. At the moment I have gravity down, secure movement in all areas of screen (none of the errors if it checks for non existant vars in a matrix), shooting in both directions. I had opening doors but my calc crashed or something and all ram cleared. Luckily I had pretty recent backups ^.^;
Is it safe to use "while" loops within "while" loops?
By the way, how do you put comments into your code? other languages that I write in use two forward slashes followed by a comment.
It would really help to keep tabs and show what does what.
Lastly, I cant get the PC program editor to work for some reason, I need it so I can make the level matrix values easier. Is there any way to get it working or any external editors? It says something about .net being needed. If it needs a windows update, no can do -_- I supposedly have a pirated windows.
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
You can use while loops within other while loops so long as all of your ends are in the right places.
You can make a line with :"This is a comment
on it, but since the interprator will store that as a string into Ans, it takes up processor time.
The short answer is you can't use comments.
My windows updates no problem, and my neighbor gave it to me for my birthday on a burnt CD he made at work. I don't think .NET requires a whole windows update, just a .NET framework update.
You can make a line with :"This is a comment
on it, but since the interprator will store that as a string into Ans, it takes up processor time.
The short answer is you can't use comments.
My windows updates no problem, and my neighbor gave it to me for my birthday on a burnt CD he made at work. I don't think .NET requires a whole windows update, just a .NET framework update.
Yeh, to bad for no comments.. =\
You can use mutiple while loops.. (While 1 means always true, so it will loop on forever.. that's why they made a command called 'stop' to kill ya program).
If you already know, you probably do, I don't care :
A while loop is a loop where as long as the statement is true, the code will be executed.. (something like that).
So:
I think I messed up on the whiles but thats every but the point..lol .... Umm.. your project is a bit difficult for pure Basic.. speed and memory wise..
Oh the matrix gumbo... I have no clue.. I don't code basic on comps..
You can use mutiple while loops.. (While 1 means always true, so it will loop on forever.. that's why they made a command called 'stop' to kill ya program).
If you already know, you probably do, I don't care :
A while loop is a loop where as long as the statement is true, the code will be executed.. (something like that).
So:
Code: Select all
1 -> a
While A<=8 ; height of screen
1 -> b
While B<= 16 ;width
output(a,b,"Y"
B+1->B
end
A+1->A
end
Oh the matrix gumbo... I have no clue.. I don't code basic on comps..