Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / WIP Snes Mode 7 game engine

Author
Message
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 7th Jun 2012 16:01
Ive started work on a new game engine that simulates the mode 7 effect from the Snes like in Mario Kart, and F Zero. Im using tier 1 and this example only took 19 lines of code to produce. Ill be releasing sample code for it in the next few days when I add in player controls and improve performance.



The video may look like the game is sometimes stuttering a bit, but this is due to the video capturing software Im using.
The Zoq2
9
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 7th Jun 2012 16:08
Looks awesome!
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 7th Jun 2012 17:41
Very cool
How did you manage to get proper speed with such detail ?
I can only get good speed on an computer but fails completely when iam doing it on an mobile device.

Do you use draw sprite?
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 7th Jun 2012 18:19
The demo runs fine on my Android phone with 800 Mhz processor. I dont use drawsprite but a combination of SetViewZoomMode and setScissor to create the effect. The map is one sprite at 1024 x 1024 pixels.

Heres the code I used.

Digital Awakening
AGK Developer
16
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Jun 2012 18:34
I don't get how it works. Well, don't know what the scissor does either. It looks really cool though

apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 7th Jun 2012 19:03
Basically Im using scissor to render the screen one line at a time from the bottom up. After I render each line I use SetViewZoomMode to zoom out from the screen a little bit before rendering the next line.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 7th Jun 2012 19:22
Quote: "Basically Im using scissor to render the screen one line at a time from the bottom up. After I render each line I use SetViewZoomMode to zoom out from the screen a little bit before rendering the next line. "

Thats extremely clever
Brilliant use of the new command
I will try your code and see wath happens?
To bad that i cant use it with my raycaster probably
Due to the fact that its probably extremely hard to aligne it to the walls?

But parts of my raycaster could be usefull for you to render the karts and trees?

You only nead to use the draw sprite command on top when you render them.

If i get some clever ideas for you to render some trees and stuff so will i post them here

Now make sure to upload the snippet to the agk codebase !!!!
Digital Awakening
AGK Developer
16
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Jun 2012 19:29
Ah, get it now I agree with Cliff that it's a very clever use of the command.

Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th Jun 2012 19:42
Very good thinking outside the box use of the new command! Cool!

Cheers,
Ancient Lady
DVader
15
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 7th Jun 2012 20:02
Impressive, most impressive, it seems you may be a Jedi after all Very nice work and 19 lines of code! I haven't looked into the scissor command at all yet, I see I need to

Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 7th Jun 2012 20:09 Edited at: 7th Jun 2012 20:10
I dont get to good framerate when running the sample

But this is an very good start

i suggest that you lower the virtual resolution to 320x240 that give an closer look to how the original looked.
And it pimped my framerate with 10 extra frames
The initial problems i see is that we nead to skip drawing some lines in the distance to get the horizion down and give an look of driving around.
Also so does the scanlines closest to the screen (Bottom) nead to be scaled so that they are slightly higher.

There is actually some code in my raycaster that can be used to get the right scale to the scanlines that i use for the floor.

But with this cool example so should we only nead to cast a single ray for each scanline to get its height.

My raycaster neads to cast rays for each pixel in width and height that is extremely slow.

But i dont know so much about the set scissors command ?
Can it cut and then resize ?
or how does it actually work?

I included an screen of my tests that shows my framerate.
Bottom image is the resolution i suggest!
Cheers.

Attachments

Login to view attachments
3d point in space
10
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 7th Jun 2012 20:14
you should enter this as a 20 line code entry

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veterian for the military.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 7th Jun 2012 20:24 Edited at: 7th Jun 2012 20:26
Tested it on android and only gets 8 fps

Could be that my phone dont like the 1024x1024 image on the sprite?

But i belive with some tweaks it could be pretty fast as we really dont nead to draw the entire screen!
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 7th Jun 2012 20:58
Thanks all for the replies. Im getting 15 - 20 fps on my Android device. Thanks Cliff for the advice. Im planning to build a FZero style racing game so ill be adding a horizon which will increase frame rate. Ill be using smaller sprite and drawing only whats on screen which will further increase fps.
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Jun 2012 14:41
Simply inspiring use of the new command set, well done!!

RickV
TGC Development Director
19
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 8th Jun 2012 18:34
TGC makes you tools, you take these tools and blow us away!

Well done, never knew this was possible.

Rick

Financial Director
TGC Team
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 8th Jun 2012 19:18 Edited at: 8th Jun 2012 19:22
Thanks. Im putting aside the weekend to work on the engine. My plan is to make a F Zero style futuristic racing game using this engine.
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th Jun 2012 20:00
Wow!

60fps on Samsung Galaxy SII (ICS)

A minor tweak - though I don't know how much effect it will have on the speed - would be to reduce the loop size by 1.

Counting from 320 to 0 is actually 321 steps - you only need 320
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Jun 2012 20:48
Quote: "A minor tweak - though I don't know how much effect it will have on the speed - would be to reduce the loop size by 1."

This is probably because the scissor command cuts from coord 320 to 320 -1 if you check the loop
Quote: "60fps on Samsung Galaxy SII (ICS)"

Thats impressive! i only get 8 with my zte skate
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th Jun 2012 21:21
Whatever the reasoning, you don't need 321 renders to draw 320 lines.

Quote: "i only get 8 with my zte skate "
Nice phone, I almost got my sister one - but they were out of stock.

With the specs of the skate, 8fps seems low - Do you have power saving enabled?

It caps the SII at 30 as the system is throttled to save power.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Jun 2012 21:27 Edited at: 8th Jun 2012 21:34
Quote: "Whatever the reasoning, you don't need 321 renders to draw 320 lines."

It start by drawing line 320 and ends with 0!
0 is not neaded and the final result will not draw more then half the loops

Quote: "Nice phone, I almost got my sister one - but they were out of stock.

With the specs of the skate, 8fps seems low - Do you have power saving enabled?"

I stand corrected as i noticed a lazy mans bugg by me
I could get the fps to show so i had it right before the scissor loop

I whas tired when i tested it!

New framerate is actually 489 on pc and 47 fps on android

Sorry apocalyp4 its better then i thought

Iam playing around with it but have some trouble getting it to rotate around the new position and not the sprite offset?
But the offset neads to be reset when moving and rotating to get the right look.
Could be some of my point of view code?

Attachments

Login to view attachments
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th Jun 2012 21:43
That's more like it

Here's the code I used to get the fps up in case anyone else needs it.

It goes right before the sync() command.

Quote: "Iam playing around with it but have some trouble getting it to rotate around the new position and not the sprite offset?"

It's using zoom mode 1, so the screen is zoomed from the middle. Try adjusting the view offset Y position to change the pretend vanishing point

Don't worry about the sprite too much just keep it in the middle of the screen.
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 8th Jun 2012 22:40
I think the best way to advance it is not to use the SetViewZoomMode command but rather SetSpriteScaleByOffset with the offset being the position of the player. Also use SetSpriteOffset to rotate the map from the position of the player. Ive yet to try it but ill post my results when I do.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Jun 2012 23:25
Quote: "Also use SetSpriteOffset to rotate the map from the position of the player. Ive yet to try it but ill post my results when I do. "

Its here i got trouble!

Iam very intrested in how you solve it
kamac
8
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 9th Jun 2012 11:25
Hey, could you post some screenshots of how would it look with



applied ? You might get better resolution!

Cheers.

Follow me on twitter! @MotionStruct
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 10th Jun 2012 11:59
Quote: "Hey, could you post some screenshots of how would it look with"

Do you mean my shoot kamac?
I havent done so much coding this weekend
Are watching alot of soccer in the european champion ship

But i am trying a new aproach then the original snippet that should make it alot easier to use tile maps for tracks and adding obstacles.

Its using raycasting and get image instead.

if it works so will i post the snippet here.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 10th Jun 2012 16:55 Edited at: 10th Jun 2012 17:16
Is this the effect you are after apocalyp4



It rotates around the kart and drives like the original i belive

The way i did it now so should it be as simple to use standard screen offset coords to se where the kart is on the track.
its neaded later on to use linecasting to render the other karts and goal posts and stuff.

I will upload the code as soon as i have clean written it,looks like someone throwed a grenade in to the compiler right now

Whas pretty hard to get it right.

But have to do the dishes and make dinner for my girlfriend now as she coming home from work very soon.


Here is my code.......



The kart image i made....


I cant upload the track image due to copyrights.

Attachments

Login to view attachments
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 10th Jun 2012 21:54
Amazing! Cliff thats exactly what I have been trying to get. I havent had any real time to work on it myself this weekend due to trying to get my other project Neon Prime HD to play nice with 1076 on the iPad. Once again thanks.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 10th Jun 2012 22:45 Edited at: 10th Jun 2012 23:38
Quote: "Amazing! Cliff thats exactly what I have been trying to get. I havent had any real time to work on it myself this weekend due to trying to get my other project Neon Prime HD to play nice with 1076 on the iPad. Once again thanks. "

I can tell you that it whas a real pain until i found out of that i neaded to reposition the track sprite inside the loop that zooms out .
And to figure out that i neaded the ScreenToWorldX( 160 ) commands
It where really simple to add the other stuff on top when i learned that you simply could use the scissor command on the whole screen after the loop also.
The scissor command is new to me but pretty fun to play with .
But worked out pretty well after all.
I will put up my updates here when i do them.
I have a few other projects aswell

And the set scissor command only works in landscape view.

The commands that dont work ok on android!
SetScissor()
ScreenToWorldX( )
ScreenToWorldY( )
Iam using 1074 because its the one that works with the goggle player.
Have anyone tested my code on newer versions if it works on mobile devices?
Nead to know before i report it as an bugg
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Jun 2012 23:58 Edited at: 11th Jun 2012 00:00
Runs sweet on 1075 - both PC (190fps - below) and android (60fps).



Nice job Cliff

Attachments

Login to view attachments
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 11th Jun 2012 00:49 Edited at: 11th Jun 2012 00:50
and here's a cap from the phone - again 1075

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 11th Jun 2012 01:15
Quote: "Runs sweet on 1075 - both PC (190fps - below) and android (60fps). "

Sounds great
I get 316 on pc and 26 on android
Quote: "Nice job Cliff "

Thanks its nice to here

I slightly updated it so it runs slightly faster on my android,something weird when adding the kart?
i now use draw sprite right before i grabb the screen.
And removed the filter on the track sprite to get that right snes feel

Could you marl test this in landscape if it works on 1075?



if it dont work simply change back the set orientation.
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 11th Jun 2012 01:53 Edited at: 11th Jun 2012 01:54
Frame Rate up to 203 on PC - I don't think my phone will go above 60 so no change there.

Orientation is now correct on Android. It forces it to landscape rather than running it as landscape in portrait

Attachments

Login to view attachments
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 11th Jun 2012 02:13 Edited at: 11th Jun 2012 02:17
I was having a look at the code and noticed that at line 51, you use the render() command.

A thought occurred to me - perhaps render() is doing more work than needs to be done. At this point you are just drawing the map sprite, so why not just do that.

Changing the render() to drawSprite( mapSpriteNumber ) has this effect...



Three times faster on my system - Neat eh?

Just hope this a real figure not just me screwing up the timing calcs

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 11th Jun 2012 07:30
paul suggested the same but i belive it gave me some weird error the first time i tested it ?
But will try it again when i get back from work
MrValentine
AGK Backer
8
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jun 2012 10:45
wow this has come a long way since I read it briefly the other day...

Keeping my eye on this...

Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 11th Jun 2012 17:52 Edited at: 11th Jun 2012 17:54
Quote: "Three times faster on my system - Neat eh?"

Slower on pc for me but faster on android
pc 190-204 fps
android 43-46 fps

Time to figure out a good track editor that works with this.
And to add some raycasting i belive?

Here is the code for the lazy ones

Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 12th Jun 2012 01:21
Todays update are these.

You can select low or high res rendering during runtime now.
Low looks like crapp on big screen but looks good on an small screen like an mobile phone.
It also runs at 56-60 fps on my slow zte skate
High runs around 46 fps.
I also added so anyone that want to pitch in can get an headstart by simply selection to show sprite the renderer uses during runtime.
The biggest part is that i have solved how to convert standard screen cordinates to world cordinates.
All info and changes are here.
Anyone else that have made any progress?

Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Jun 2012 21:07
Todays update are small but i belive i have partially solved the sprite rendering
First so did i try raycasting but its slow and looked weird.

Now are i doing it alot simplier
iam using a sprite in the same size as the scissor cut that moves with it,and check for collision with sprites to place them right on screen.
iam doing it by simply geting the collison x cordinate on that sprite.
And by this simple task do we get the x coord the sprite should be drawn on screen.
The harder part is the right scale and y coord placement
Initial tests are looking good.

Anyone else made any progress?
swissolo
9
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 14th Jun 2012 21:46 Edited at: 14th Jun 2012 21:47
I just saw this code, and I must say, it's quite impressive I'm curious though, is this bending intentional? (I used an image with a boarder to show the effect)

Notice the tip end...

I don't know what computers you all are running, but I get around 2500 FPS PC (60 on android with cap)

swis
Joined: Tue Dec 16th 2008

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Jun 2012 22:29
Quote: "I just saw this code, and I must say, it's quite impressive I'm curious though, is this bending intentional? (I used an image with a boarder to show the effect)"

Its a plain bug

I havent updated the source here when i noticed it simply.

Change...


to this....


set view zoom first in the loop
MikeMax
AGK Academic Backer
7
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 14th Jun 2012 22:34 Edited at: 14th Jun 2012 22:35
Cliff,

Here is my concept : (not tested lol)



(YMax is "YMin" in fact .. because top of screen has Y=0 :p)
swissolo
9
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 14th Jun 2012 22:40
Quote: "Its a plain bug

I havent updated the source here when i noticed it simply."

Ahhhh yes. I hadn't looked into the code until just now, that makes perfect sense. Looks even better now.

swis
Joined: Tue Dec 16th 2008
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 15th Jun 2012 00:15
Quote: "Here is my concept : (not tested lol)"

Looks intresting

If my latest attempt dosent work so will i have to check your theory.

My latest test is pretty plain.

During the draw loop so do i grabb world cordinates from the scissor command.

I use these arrays.
REM // 0 is x=0 and 1=screenwidth
dim ScreenWorldCoords_X[ScrHeight,1,ScrWidth]
dim ScreenWorldCoords_Y[ScrHeight]

If it works the way i want so should i be able to do an simple position check and get the screen position in the same loop without alot of math.

First check ScreenWorldCoords_Y[ScrHeight] and if they match.
ScrHeight do i get from the above check.
Then check ScreenWorldCoords_X[ScrHeight,1,ScrWidth] if they match.

This check should be as simple as.
if ScreenWorldCoords_X[ScrHeight,0,ScrWidth]>spritex and ScreenWorldCoords_X[ScrHeight,1,ScrWidth] <spritex.

It neads to be tested first


But please post a sample snippet of your theory !
If its used so will you be credited in the open source
Quote: "Looks even better now. "

Sounds great
apocolyp4
9
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 15th Jun 2012 13:20
Great work guys. Sorry that Ive not been able to do any work on it for a while. Too busy hacking the Playbook tier 1 project to allow some 107 commands. Im hoping to work on it sometime next week after I manage to get http commands working on the tier 1 for PlayBook.
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 20th Jun 2012 03:22 Edited at: 20th Jun 2012 03:58
Quote: "If it works the way i want so should i be able to do an simple position check and get the screen position in the same loop without alot of math."

I tried a similar thing a while back with sines and cosines - I used a lot in the loop and was looking for a performance tweak. I pre-calculated them and stored them in an array. It worked out slower.

It seemed (in my case) that AppGameKit could calculate the values faster than it could retrieve pre-calculated results from an array. Weird.

To add something - I was tinkering around...

A variation on the theme, but basically the same technique.

Use left / right cursor keys to scroll left / right
Use up / down cursor keys to increase / decrease height.

Depth scroll is constant.


Media required is attached.

Attachments

Login to view attachments
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 20th Jun 2012 03:27 Edited at: 20th Jun 2012 04:00
And the resulting effect is a 3d Scrolling Desert.


(not the best cap in the world - movement makes it look so much better)

It uses UV Scrolling on a stationary sprite.

Edit: The motion blur in the cap is an accidental side effect of the texture scaling - but I'm going to claim it was intended

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Jun 2012 21:34
Very nice marl

Please post it in the agk codebase,could be usefull in the future

Your sample feels a bit hard to make an kart game of ?

I am working on an new concept as no one have worked yet on position sprites right on screen.

The problem is that they have to position on the fake 3d render exactly the same as the track.

But drawn outside the loop and scaled right.
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 20th Jun 2012 22:19
Quote: "Your sample feels a bit hard to make an kart game of ?"

PilotWings?
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Jun 2012 01:41
Quote: "PilotWings?"

Old classic

I belive my rewritten engine where i scale the sprite instead is good for that too?

It simply dosent work with setview zoom

All coords and math gets messed up !

This will be my last attempt before i throw in the towel

Login to post a reply

Server time is: 2019-07-22 03:25:16
Your offset time is: 2019-07-22 03:25:16