+Philsan Posted November 29, 2007 Share Posted November 29, 2007 I am programming a Basic game. The attached image describes it very well. As you can see it's like Heaven's Diablo but it's far better (better graphics, no rpg part, no redifinible character sets, no music, no machine language...). Just kidding! Seriously talking, nothing important, only a program to make me enjoy my old Atari. I have two NOOB questions. How can I make the player go to another room? With this code (X1 and Y1 are player position, DX1 and DY1 are joystick movements like +1, 0 or -1) 340 X1=X1+DX1:Y1=Y1+DY1 350 IF X1<62 THEN X1=62 360 IF X1>187 THEN X1=187 370 IF Y1<37 THEN Y1=37 380 IF Y1>90 THEN Y1=90 the player cannot go over the wall but I don't know how to check if the player wants to go to another room pushing the stick up, down, left or right near the doors to go north, south, west, or east. The second problem. How can I build the map of the castle? In other words, how can I know which room I have to draw when the player enters a door and exits a room? I know that the skills level here are a lot higher but... have mercy! Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 29, 2007 Share Posted November 29, 2007 Don't suppose those player objects are Players? Then you could just leave out the bounds checks and use collision registers to help you out. But, I guess you're just drawing them, so: Throw out the bounds checks - just use LOCATE. Then, if you hit a wall, don't move the player. Maintain "old" values of X and Y so you can restore them if a movement is illegal. Then, for that room, a Y value of about 4 would be leaving the room. Or, just leave the door part without the line and let BASIC receive an ERROR - 141. Trap the error to a bit of code that performs a leave room/enter new room type function. Map of castle? Probably a string array. Have a certain byte value for each type of room. Then, use a formula to work out which character of the array you need to reference for a room. e.g. castle has 40x20 rooms would need 800 bytes. So, the byte you'd need would be X+1 + Y*40 (assuming X and Y start at 0). Quote Link to comment Share on other sites More sharing options...
+Philsan Posted November 29, 2007 Author Share Posted November 29, 2007 The player (and the monsters) are PM sprites. Quote Link to comment Share on other sites More sharing options...
+Philsan Posted November 30, 2007 Author Share Posted November 30, 2007 I've solved the first problem with 4 lines like this one: IF X1=100 AND Y1=37 (player position in front of north door) AND DX1=0 AND DY1=-1 (joystick moved up) THEN GOTO... (draw a new room) Not very elegant but it works... I am thinking about the second problem (map of the castle) but I don't know exactly what I have to write in Basic... Quote Link to comment Share on other sites More sharing options...
Mirage Posted November 30, 2007 Share Posted November 30, 2007 This is a fantastic book on mapping techniques in BASIC. This is for text adventures, but it's the same exact process. Once you understand how to do it in BASIC, you should be able to use the same technique in any other language you learn. This book is very easy to understand and to-the-point. You should be able to breeze through it in no time, as I did. Make it all the way through the book and you'll learn a lot more than just mapping. Creating Adventure Games On Your Computer (1983). http://www.atariarchives.org/adventure/ Quote Link to comment Share on other sites More sharing options...
Goochman Posted November 30, 2007 Share Posted November 30, 2007 As most have said here it shouldnt be too hard to know if you've hit a door - you will have 4 exits max (N, S, E, W) so these should map to X=0, Y=0, X>187, Y>80. I would keep my map in a matrix as mentioned above - with Basic you will be limited to the amount of rooms you can keep unless you disk swap them in and out. I created an 'ultima' style game in basic many moons ago and could get 6 or 9 screens in memory before using a load to overlay code lines with a new screen (only did final room like that as it was a new technique for me). Since you will prob have few rooms it shouldnt be too hard to calculate next room. attached is pic of my game - happy to give it to you if you want to puruse the 32k of basic code in it Quote Link to comment Share on other sites More sharing options...
+Philsan Posted November 30, 2007 Author Share Posted November 30, 2007 (edited) This is a fantastic book on mapping techniques in BASIC.Creating Adventure Games On Your Computer (1983). http://www.atariarchives.org/adventure/ The chapter Creating the floor plan is perfect for my needs! The only problem is that sometimes I have troubles printing from AtariArchives (the right margin is cut). Since you will prob have few rooms it shouldnt be too hard to calculate next room.Attached is pic of my game - happy to give it to you if you want to puruse the 32k of basic code in it I will make few rooms, only to test my (limited) programming skills. Every room is made with some PLOT and DRAWTO commands; I like to draw using the background color and then suddendly make appear the room structure with the SETCOLOR command! I think your program is too advanced for me so, for the moment, I will not ask to reveal it to me! Thanks to everyone! Edited November 30, 2007 by Philsan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.