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 »

47
##### General Discussion / Great youtube series
« on: October 10, 2011, 10:57:29 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
##### News and Announcements / Re: New community ezine! BASIC Gamer - A FB/QB64/QB games mag
« on: August 02, 2011, 08:34:01 AM »
Awesome! Great work Lachie. Good idea not to make this a free-for-all -- anything submitted gets included -- magazine. Quality counts.

51
##### General Discussion / Re: Contemplating about starting a QB/FB/QB64 Games eZine
« on: July 24, 2011, 08:11:47 PM »
I like the name.

52
##### General Discussion / Re: Contemplating about starting a QB/FB/QB64 Games eZine
« on: July 23, 2011, 11:17:28 PM »
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
##### Site Suggestions, Comments and Critiques / Re: FBGD needs a redesign...seriously
« on: February 03, 2011, 10:23:18 PM »
I'm thinking more like 1989. You know, the days of text-based browsing.

56
##### Site Suggestions, Comments and Critiques / Re: FBGD needs a redesign...seriously
« on: February 03, 2011, 09:32:53 PM »
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
##### Site Suggestions, Comments and Critiques / FBGD needs a redesign...seriously
« on: January 28, 2011, 06:45:21 PM »
It just looks so...1999.

I can offer my services for...\$0 an hour.
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 »