I need help with SDL for a RPG Game

Game development specific discussions.
Endevor
Posts: 9
Joined: Feb 19, 2009 2:21
Contact:

I need help with SDL for a RPG Game

Postby Endevor » Feb 19, 2009 2:45

Me and some friends are designing a RPG game and we ran into wall with FB graphics so we heard about SDL. We have made a map creator to paint maps then it puts it to the grid and saves the grid to data each box having a number, each number representing a certain terrain. We then made a re generator which takes that data and scans through all the numbers thus reprinting out a map according to the numbers. We want to be able to take that and print a little man out and have him walk around to our command. We had first accomplished this by drawing a map in paint and reprinting it constantly as alpha so you could still see the little man and we had him moving around. The reason for reprinting the map over is to get rid of the trail left by the character moving around, and it works with drawing it up in paint and making the data manually, but it wont work with the map generator. Because the map generator prints the map out in sections instead of one picture as a whole so we cannot reprint it out like we were doing before. That's when we heard about SDL and it's graphics capabilities so we started to look into it. The problem is, none of us really have a clue what we're looking at. We looked up tutorials and learned how to print a picture in any location we want, but we can't get it to move around like with using the arrow keys.

Basically if you didn't understand what we're doing, which is understandable with my explaining skills, We want to put up a picture and have a character move around on the screen by pixel and not leave a trail and still retain the background. If someone could post a basic code that'll do this, explain how to do this, or show me somewhere that'll tell me how to do this, that would be awesome. Thanks
AlexZ
Posts: 55
Joined: Aug 09, 2007 9:23

Postby AlexZ » Feb 19, 2009 6:28

I don't understand your explanation but I recommend using SFML instead of SDL.
Endevor
Posts: 9
Joined: Feb 19, 2009 2:21
Contact:

Postby Endevor » Feb 19, 2009 19:29

I am required to use SDL for this project. I need help on being able to output a picture and then move it around using the arrow keys. If someone can show me the basic code for doing this with SDL that is what I need. If anyone could help, it would be greatly appreciated.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Feb 19, 2009 21:10

Endevor wrote:I am required to use SDL for this project. I need help on being able to output a picture and then move it around using the arrow keys. If someone can show me the basic code for doing this with SDL that is what I need. If anyone could help, it would be greatly appreciated.


I have no idea why you need SDL. FB gfx can do this quite easily. If I new anything about SDL I would tell you. I personally use FG gfx for all of my games.

iMakeGames.Com

Shameless Plug! :)

If you would like an example of how to move gfx around using FB I would be happy to post it. Plus there are tons of game source code examples you can download from Games.FreeBasic.net.

-Vince
Endevor
Posts: 9
Joined: Feb 19, 2009 2:21
Contact:

Postby Endevor » Feb 19, 2009 21:49

Well actually today with playin around with SDL we got it to work in a real slick way that I really like and I'll post a basic tutorial of it for nyone wanting to learn about it.

I'm like you, I usually use just FB graphics, but with what we were doing, the character that we were printing out as a picture, it would leave a trail whenever we moved it over the background. So we would reprint the background to cover up the trail. Our problem came when we switched how we printed the problem so it was printing out parts of the map instead of the entire picture as a whole. This sent us back to the problem of the character leaving a trail which we really couldn't get past. So now we're using SDL which does this in a real slick way. If you really want to look at what we are doing, I'd be happy to show you.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Feb 19, 2009 22:39

@Endevor

I still don't see why you would need SDL.
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Postby Lachie Dazdarian » Feb 19, 2009 23:11

Yeah, I agree with vdecampo here. I think this is a classic example of library switching misguided by belif that one can't do what you need.

I recommend you check my tut How To Program A Game With FreeBASIC - Lesson #1 before giving up on FBGFX: http://lachie.phatcode.net/articles.php

Also, check my pixel by pixel and screen by screen scrolling engines to see how to draw a tile-based map: http://lachie.phatcode.net/downloads.php

Paste your background (or tiles in sequence), paste your sprites/particles over that, loop. Simple as that.

Nobody says you shouldn't use SDL, but I think you should find better reasons.
Dr_D
Posts: 2396
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Feb 19, 2009 23:13

Hi. SDL isn't necessarily horrible or anything, but I would just like to throw my 2 cents in and back vdecampo up on recommending fb's built in gfx library. It sounds to me like you weren't refreshing the back buffer on each frame. You might try something like this.


1) Get_Input
2) Process_Movement
3) Draw_Background
4) Draw Character
Endevor
Posts: 9
Joined: Feb 19, 2009 2:21
Contact:

Postby Endevor » Feb 20, 2009 3:24

Thanks for the suggestions, but I found a way to work with SDL. you guys probably are right, they're probably are better libraries out there and there are ways to do it with just FB, but this is actually a project for school and we are limited with what we use and we're also still beginners. When I'm on my own I'll probably get into stuff like that. Thanks a lot for the suggestions though[/i]
arenth
Posts: 511
Joined: Aug 30, 2005 6:22

Postby arenth » Mar 02, 2009 23:46

Ok not to be controversial or anything but telling him what to use rather then helping him use what he wants is very elitist, and pointless. That said:

Endevor what you're going to need to do is load up your background, load up your sprite, and on each frame blit your background in one place, and your sprite at its movement coordinates.

The following lacks error checking:

*Link to Example*

This should give you an idea of the workings of SDL, I make no guarantee that it will build as I didn't test it.

For further reading that is a must for SDL: *HERE*

Its in C, but if you have trouble converting from C to FB, you're in more trouble then I can help you with.
Endevor
Posts: 9
Joined: Feb 19, 2009 2:21
Contact:

Postby Endevor » Mar 03, 2009 0:25

Thanks a million man, you're the only one's actually answered my question. I did get it to work and it works real nicely, thanks so much. I have another question though if you can help. I'm looking at using the mouse in my project and I know how to use it with FB, but it's kinda useless once you switch to SDL because it uses an SDL app instead of FbideTEMP which is probably "duh" to all of you. How can I use the mouse using SDL?
arenth
Posts: 511
Joined: Aug 30, 2005 6:22

Postby arenth » Mar 03, 2009 4:30

SDL actually has two ways to collect information about the mouse, there is the mousemotion/mousebuttondown/mousebutton up events, and those will only be triggered whenever any of those actions actually occur.

MouseMotionEvent

MouseButtonEvent

The second is GetMouseState

It takes the pointers of two integers as arguements, and returns the button state. It will be updated every time pollevents is called. So you will still need the event poll, but it will be constantly updated.

Like I said in my previous post any of the information you need is in that link, anything to do with input will be under the Events heading.
Endevor
Posts: 9
Joined: Feb 19, 2009 2:21
Contact:

Postby Endevor » Mar 03, 2009 4:51

sweet, thanks man, I'll try to let you know how this all turns out

Return to “Game Dev”

Who is online

Users browsing this forum: No registered users and 3 guests