English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 18 August 2011, 11:26   #81
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
Thank you.

I've now written down a list of things to be done on the code and gfx side.
When I started I was still learning Blitz, so a lot of code had to be rewritten later, and I'm still in that process.
Several things, like the casting menu, haven't made it on that list. Nevertheless, this is the first time I can say that, once these things make it into the game, it will be ready for the masses!

It will be a small world beta test, but I expect it will be fun.
r0ber7 is offline  
Old 19 August 2011, 11:58   #82
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174


Question:

I'm trying to share an array of newtypes in a function.
The newtype is called .obj and the array (objects.obj) holds data for several objects.

Somehow this doesn't work:

maingame.bb
Code:
; newtype definition
INCLUDE "obj_newtype.bb"

; object array
objects_n=3
Dim objects.obj(objects_n)

INCLUDE "obj_icheck.bb"
obj_icheck.bb
Code:
Function obj_icheck{ obj_i }
SHARED objects
...
If objects(obj_i)\status = 0
...
Tells me "Array not yet Dim'd", when I did do a Dim, except I did it in the maingame.bb, and I'm trying to share it with obj_icheck.bb. I've tried several notations like SHARED objects.obj, SHARED objects(), and so on, but it keeps telling me this. I'm not exactly sure if there's a specific way of sharing arrays of newtypes, so I'm asking for your help, mighty Blitz people.
r0ber7 is offline  
Old 19 August 2011, 18:28   #83
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
I'm more of a C and AmigaE expert but here's a thought: Maybe you shouldn't be using an array to hold your objects directly. You've already got a type specification for a structure. I'm not sure if Blitz2 supports references to objects but that's got less overhead than passing an array reference and an offset and indexing each time you use an object.

In Assembly it would be implemented as a pointer held in an address register to each structure, then passing the pointer to the specific structure to your obj_icheck so that you're doing the indexing only once.

I hope this helps.
Samurai_Crow is offline  
Old 20 August 2011, 00:51   #84
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
For starters if you're going to share arrays, you must include the brackets too - so it'll have to be SHARED objects().

Have you tried not using Includes and just putting all the relevant code into one source file? Maybe, for whatever reason, the compiler just doesn't like you using Includes in this situation, I'm not sure.
Graham Humphrey is offline  
Old 20 August 2011, 01:04   #85
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
When I use SHARED objects() the error changes to "Syntax error", relating to:

Code:
If objects(obj_i)\status = 0
Yet, before (when it was obj_ball\status) no problem occurred, and I don't see any error in syntax... I'll try throwing everything in one file tomorrow, even though I was trying to avoid doing that.

Thanks for the help.
r0ber7 is offline  
Old 21 August 2011, 15:52   #86
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
It's working!

I just threw in the Dim in the obj_icheck.bb. Now I can REALLY make everything bounce and slide whenever I want, woohoo!
I've also finally set up a null-modem cable link with my old A1200 so I can test the game on a true original Amiga.
r0ber7 is offline  
Old 21 August 2011, 22:20   #87
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
Nice work man

I look forward to covering your work in Amiga Future at some point when you're at the stage where people can play it
Graham Humphrey is offline  
Old 22 August 2011, 16:33   #88
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
Quote:
Originally Posted by Graham Humphrey View Post
Nice work man

I look forward to covering your work in Amiga Future at some point when you're at the stage where people can play it
I am honoured.

Meanwhile, I'm coding in some axe throwing. :-)

Last edited by r0ber7; 22 August 2011 at 17:13.
r0ber7 is offline  
Old 25 August 2011, 23:25   #89
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
The game is coming along nicely. Start menu and intro are done, and I've added a new enemy and some other stuff too. Now, for my question (as always).

I need help calculating the trajectory of things that get thrown around in a straight line, like fireballs and axes.



B = starting point (start_x, start_y)
A = target (dest_x, dest_y)

Right now I do this: First I calculate the length of the hypotenuse, and determine velocity and set timer to zero.

Code:
v = 8.5
t = 0.0
boo = (start_x-dest_x)*(start_x-dest_x)
baa = (start_x-dest_x)*(start_x-dest_x)
hyp = Sqr( boo  + baa )
Then, I do this every Vwait until the object reaches its target.

Code:
t = t + 0.5
boo = (dest_x-start_x) * v * t
baa = (dest_y-start_y) * v * t
x = start_x + boo / hyp
y = start_y + baa / hyp
While this works, it eats the CPU. Whenever I launch a fireball and there are more than two moving objects around, the game slows down badly. I'm using quicks, not floats, but that doesn't help much. Could there be a more efficient way of calculating this? I can't calculate before the game launches & throw it in an array either, since the targets are always different.

r0ber7 is offline  
Old 26 August 2011, 01:19   #90
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
The fastest way is to use an iterative approach and calculate the directional vector and scale its length to that of your velocity, and simply add this vector to the position every frame:

Code:
Initialization:

dx = dest_x - pos_x
dy = dest_y - pos_y
scale = velocity / sqrt(dx*dx + dy*dy)
dx = dx*scale
dy = dy*scale

For every image frame:

pos_x = pos_x + dx
pos_y = pos_y + dy
This incurs some slight aliasing, and depending on how many steps are needed to reach the destination and the precision of these quick floats, your target position in the end may be off by a pixel or two.
Leffmann is offline  
Old 26 August 2011, 10:38   #91
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174


Awesome! It's working, at blazing speed! Thank you, this has been troubling me for a long time.
r0ber7 is offline  
Old 27 August 2011, 23:54   #92
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
So, I'm at the point that I've put in so much stuff I get out of memory errors.

I have several ideas to get rid of these, some are a bit too code specific to mention here. But, one things bugs me a bit.

There's a start menu. After clicking "play" the game starts. Then after you die or hit escape, you go back to menu. Before the menu loads I do this:

Code:
		stopmodule
		for r=0 to 10 : free sprite r : next
		for r=0 to 99 : free shape r :next
		for r=0 to 5 : free bitmap r : next
		for r=0 to 3 : free palette r : next
Yet, for some reason this doesn't free up all memory that was used ingame? How about Displays and Coplists? I just leave them lying around now, cause Free Coplist / Display doesn't work. Either way I'll get around this, I'm just wondering: does Blitz have more functions to clear memory, and how do I use them?

Last edited by r0ber7; 28 August 2011 at 00:42.
r0ber7 is offline  
Old 28 August 2011, 11:06   #93
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
Would an array of 640 quicks take up a lot of mem? I have two approaches to ground detection, one involves an array. Is there a way to see which things occupy how much memory?
r0ber7 is offline  
Old 28 August 2011, 21:47   #94
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
Solved memory problems, I didn't realize Free Coplist was an option. Game is running faster than ever before. I have room to add some spicey stuff I've been planning, it's way too fast now.
r0ber7 is offline  
Old 30 August 2011, 23:33   #95
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
Ok guys, a quick update.

I've worked on the game a lot the last week and there are only a few things left to add before I can release world 1 as alpha test. There will be 2 gameplay modes. In the first one (adventure) you follow the storyline. In the other one (survival) you blast vikings for points until you die.

Before first release these are left to do:

- a proper "getting hit & dying" procedure for the wizard (right now it's just halfway)
- different ingame music which better suits the atmosphere
- highscores
- fix a few glitches
- test on a real A1200, and in WinUAE (developing in e-uae on linux)

I've added quite a bunch of stuff, which I won't share until first release. :P Also don't expect too much, world 1 isn't very big because it's drawn by hand. Well, by mouse. No random generation of objects or anything. It's an island of 1280x256, but it's big enough to fight vikings on, heh.

The coming two weeks I'll be starting at my new job, so I probably won't have much energy to work on this. Which is why I'm posting this too, just to say, I will release at least this one world in the near future. Seeing how winter is coming, it's quite likely I'll be adding worlds and updating after first release.

So I could say, "expect an alpha release in late september", but I won't because I don't like having a deadline. So no promises. But it'll probably happen anyway.

Last edited by r0ber7; 31 August 2011 at 00:02.
r0ber7 is offline  
Old 31 August 2011, 05:29   #96
whitegiant89
Lone CBM user
 
whitegiant89's Avatar
 
Join Date: Mar 2007
Location: Atherton / Australia
Age: 52
Posts: 148
Send a message via MSN to whitegiant89
Sweet cannot wait for a look at the real thing.
whitegiant89 is offline  
Old 05 September 2011, 18:38   #97
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
I've actually been coding in between shifts. I said no deadlines, but hey. If all goes well...

First alpha release: september 11th.

Will be announced in the EAB Gaming Factory.
r0ber7 is offline  
Old 05 September 2011, 22:47   #98
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
Cool. I hope you make your deadline (or thereabouts) as I have the week after that off work. Plenty of time to play your alpha release

(don't worry if you miss your deadline, my demo is 4 months later than planned and still not finished!!)


Regards,
Lonewolf10
Lonewolf10 is offline  
Old 06 September 2011, 17:28   #99
r0ber7
it's all in your head
 
r0ber7's Avatar
 
Join Date: Feb 2011
Location: The Netherlands
Posts: 174
Quote:
Originally Posted by Lonewolf10 View Post
(don't worry if you miss your deadline, my demo is 4 months later than planned and still not finished!!)
Thank you. But, if I say I'll release then, I will. It might not have everything I want to have in there, but I think it's ready for testing anyway. And besides it's just the first world. I've already got plans for the two worlds after this one, but why wait when the first world is more or less playable. I'll be going Minecraft style, updating now and then with new stuff.

P.S. Considering this is a Coder's Heaven, I'll only post coding related stuff in this thread from now on. Anything else will be in the Game Factory.
r0ber7 is offline  
Old 06 September 2011, 19:14   #100
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
You got a name for this game yet? Or are you waiting until the 11th before you reveal it?
Graham Humphrey is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz2: Hires laced BippyM Coders. Language 25 06 February 2020 01:07
Blitz2 keyboard issues htdreams Coders. Blitz Basic 2 16 August 2013 15:58
Blitz2 Newcommandset BippyM Coders. Language 0 21 July 2012 23:59
Blitz2 Manual AlfaRomeo Amiga scene 18 01 May 2009 10:53
Embed data in Blitz2 programs oRBIT Coders. General 25 06 April 2007 19:49

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:42.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12281 seconds with 13 queries