Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Small tile engine.

Author
Message
Diablo 98188
21
Years of Service
User Offline
Joined: 12th Sep 2004
Location: In front of my computer.
Posted: 21st Jul 2005 23:57 Edited at: 23rd Jul 2005 07:23
Hey, like i said in my post about transparency, im working on a rpg. I made the following code as a basic tile engine, it is no where near done, but i was wondering if you could comment on it.

If you have any comments, good or bad, i would love to hear it. And also, does anyone have an idea on how i can write down on a .dat file where everything goes, and my game loads them up as i go to the right map. Thanks
-Diablo98188


(the image jhonny is just a grass tile, i named it johnny for testing purposes only.)


edit 1: Fixed the code thingy.

"May the fires of the underworld burn you"
- ME ^_^
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 22nd Jul 2005 23:47
Source code box displays an error, use a code snippets box to display your code.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Jul 2005 07:34 Edited at: 24th Jul 2005 07:43
One of the things you need to learn is spaceing. When you make a for next loop and if statements you need to space it in such a way that you can see at a glance where the for next loop begins and ends and where any if statements begin and end. In this case it's easy but the bigger the nest the harder it is to see without spaces. A lot of people use tabs but to me just one space per nested loop is fine. No matter how many spaces you use always make sure the begining of a loop and the end line up.

Here I forced the screen mode (you never know what people use so always force it on them). Syncing is a way to make sure the screen updates when you want it to... and not at every screen change (the default). "sync rate 0" means the computer will sync the display as fast as the computer running it can handle. "sync on" turns on the ability to "sync" when you want. In your code I put sync at the bottom so when it's done putting all the sprites on the screen you'll see them pop up at once.

I changed the "x=x+32" and "y=y+32" with "inc x,32" and "inc y,32" which do the same. If you just wanted to add one then all you need is "inc x". The opposite is "dec x". I also moved the "inc y,32" under the else statement so that it works properly (so that if y=0 inside the if statement it won't add another 32 when it leaves the if statement).

Hope this helps:



As for writing/reading files start by looking at the Darkbasic help files. (F1, click on Commands, then click on File Commands) They'll tell you the proper syntax for writing files. If you get stuck post.
Diablo 98188
21
Years of Service
User Offline
Joined: 12th Sep 2004
Location: In front of my computer.
Posted: 26th Jul 2005 01:19
Ok, i see what you are doing. Now another question, should i store the maps in a ini file or should io store it in the code? Thank you....

"May the fires of the underworld burn you"
- ME ^_^
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Jul 2005 04:33
It would be better to store it in a file. That way you can create a separate editor to make the maps. If it's in code you'd have to cut and paste the map data anytime you make a little change.

Login to post a reply

Server time is: 2026-06-12 11:22:28
Your offset time is: 2026-06-12 11:22:28