10.03.2019 - Round 1 results of our "A Love Letter For FreeBASIC" game dev competition have been published. Please be sure to check the results thread: http://games.freebasic.net/forum/index.php?topic=629.0. Don't forget that the competition is continuing with a round 2, lasting till 29th of April, 300 USD first prize. Stay tuned!

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ecxjoe

Pages: 1 2 3 [4] 5 6
46
Game Dev / Re: FB games with included sources
« on: October 13, 2011, 10:35:28 PM »

48
Programming / Re: Background scrolling and scrolling in general
« on: October 06, 2011, 10:53:42 PM »
I like to have a camera object point to whatever object I want to follow:

If you're objects are in an array:

Code: [Select]
type CameraType
    index as integer    '// index of scene object to track
    x as double
    y as double
end type

dim camera as CameraType

camera.index = objectIndex
camera.x = object(camera.index).x
camera.y = object(camera.index).y

But I like using pointers:

Code: [Select]
type Vector
    x as double
    y as double
end type

dim camera as Vector ptr

camera = @object.position  '// position is Vector pointer

This way, if any object has a position vector, the camera can point to it.


Then you need to convert the camera to scene coordinates and add some rules to stop the scene coordinates at the edge of the map.

Code: [Select]
dim scene as Vector
dim edge as Vector

'// convert camera coordinates to scene coordinates
scene.x = camera->x - screenWidth/2
scene.y = camera->y - screenHeight/2

'// make sure the scene coordinates stay in bounds
edge.x = mapWidthInPixels - screenWidth
edge.y = mapHeightInPixels - screenHeight
if scene.x < 0 then scene.x = 0
if scene.y < 0 then scene.y = 0
if scene.x > edge.x then scene.x = edge.x
if scene.y > edge.y then scene.y = edge.y


The screen coordinates are relative to the scene coordinates, so for example:
Code: [Select]
screen.x = object.x - scene.x

For scrolling the background, GET and PUT take a lot of memory and computing time relative to other techniques. But you can pull off a trick: give the background its own wrapping border, and the reposition the x,y copy-coordinates when you get close to the edge:

Code: [Select]
scene.x = 0: copy.x = 0
.......@.......|.......@.......|
......&$#......|......&$#......|
....DDDDDDD....|....DDDDDDD....|
.....DDDDD.....|.....DDDDD.....|
......DDD......|......DDD......|
.......D.......|.......D.......|

scene.x = 4: copy.x = 4
...@.......|.......@.......|
..&$#......|......&$#......|
DDDDDDD....|....DDDDDDD....|
.DDDDD.....|.....DDDDD.....|
..DDD......|......DDD......|
...D.......|.......D.......|

scene.x = 8: copy.x = 8
.......|.......@.......|
#......|......&$#......|
DDD....|....DDDDDDD....|
DD.....|.....DDDDD.....|
D......|......DDD......|
.......|.......D.......|

scene.x = 12: copy.x = 12
...|.......@.......|
...|......&$#......|
...|....DDDDDDD....|
...|.....DDDDD.....|
...|......DDD......|
...|.......D.......|

scene.x = 16: copy.x = 0
.......@.......|.......@.......|
......&$#......|......&$#......|
....DDDDDDD....|....DDDDDDD....|
.....DDDDD.....|.....DDDDD.....|
......DDD......|......DDD......|
.......D.......|.......D.......|

scene.x = 20: copy.x = 4
...@.......|.......@.......|
..&$#......|......&$#......|
DDDDDDD....|....DDDDDDD....|
.DDDDD.....|.....DDDDD.....|
..DDD......|......DDD......|
...D.......|.......D.......|

...and so on...

copy.x = scene.x % perceivedBackgroundWidth

49
News and Announcements / Re: BASIC Gamer Issue #2
« on: October 02, 2011, 09:45:14 PM »
Yeah! When can we expect issue #3?

50
Awesome! Great work Lachie. Good idea not to make this a free-for-all -- anything submitted gets included -- magazine. Quality counts.

51
I like the name.

52
Do it!

53
Work In Progress / Re: Text adventure
« on: July 12, 2011, 09:26:21 AM »
I started a web-based text adventure in PHP and Ajax not too long ago. I had a good system going but I didn't keep up with it. I think I'll port it to FB and see how it goes.

54
General Discussion / Back from hiatus
« on: July 11, 2011, 12:25:20 PM »

55
I'm thinking more like 1989. You know, the days of text-based browsing.

56
I frankly like the retro look. Do we need a new system?
I like the idea of a retro-style theme. I was thinking of something with a web 2.0 sort of look (a bit like bored.com), but with some retro-game-style inspiration. I'm not too great at web design, but I'll see what I can come up with.

57
It just looks so...1999.

I can offer my services for...$0 an hour. ;D
Did you code the site yourself in php, or are you using some configured system?
Just saying there's lots of room for improvement. I would like to help where I can.

58
General Discussion / Re: Why, JavaScript, why?
« on: January 28, 2011, 06:33:38 PM »
I might be able to help...if you haven't solved it yet. What are you trying to accomplish with your code, in more detail? Are you just swapping the background color every second or so?

59
General Discussion / Re: Why do you chose FreeBASIC?
« on: January 28, 2011, 06:24:08 PM »
I started learning with Commodore 64 Basic. Then I moved to Qbasic because it was way more awesome. Then I moved on to Freebasic because of the multi-platform support.

60
General Discussion / Re: BASIC vs. Flash
« on: January 27, 2011, 08:32:25 PM »
Flash games are more accessible...but they still have to be good to be popular. The same rules apply: if people love it they'll play it; if not they'll go somewhere else. You do, however, reach a larger market with a browser-based game. Rather than losing a percentage of potential players through the process of downloading and installing your game (consider yourself lucky if 50% of the people that hit your page download and play your game), you keep most of them since all they have to do is wait a couple seconds for the app to load. So your best bet is to streamline the process as well as you can. Make it simple to download and install, and then hook them within the first 5 minutes with great content. For small games, I would want to be playing it within a minute I from the time I click 'download here.' A big factor of the process is how well you market your game. Does it look fun? Does it look like a virus? Will I want to come back to playing it a second time? Is it cool enough to share with my friends and post a link on Facebook?

Pages: 1 2 3 [4] 5 6